Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a PostGIS spatial enabled table with the states in the US. How can I write a query selecting all touching states to a named state. Like this :

Select * from States Where geom touches (Select geom from States Where name = 'Oklahoma') 

Thanks ..

share|improve this question
up vote 7 down vote accepted
WITH state as (SELECT geom FROM States
 WHERE name = 'Oklahoma'
SELECT States.* FROM States,state WHERE ST_Touches(state.geom, States.geom)
share|improve this answer
For the OP's benefit, the first part of this query ("WITH state as (...)") is called a common table expression. – katahdin Mar 24 '13 at 22:10
Thanks zimmi and katahdin great help :) – Lan1 Mar 26 '13 at 8:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.