Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

1 Answer

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
1  
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
add comment

Your Answer

 
discard

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.