Skip to content

Instantly share code, notes, and snippets.

@mbforr
Last active January 8, 2023 10:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mbforr/f9c61d7c7825d9ae5e037f0dd9e693cd to your computer and use it in GitHub Desktop.
Save mbforr/f9c61d7c7825d9ae5e037f0dd9e693cd to your computer and use it in GitHub Desktop.
select
state_name
from
`bigquery-public-data.geo_us_boundaries.states`
where
st_touches(state_geom,
(
select
state_geom
from
`bigquery-public-data.geo_us_boundaries.states`
where
state_name = 'Virginia'))
# this query will select all states that touch Virginia
# we can select the geometry of Virginia in a subquery
# which will return all the states it touches in our main query
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment