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 table that containing placename regions and another table of roads. I have another table that containing centroid of both placename region and roads.The table structure of third table is placename,Roadname,x,y. I want to update the placename field of the roads which are passing through the corresponding placename region. I used the following query:

Update haryana set placename = from placename_region where haryana.the_geom in (select st_centroid(ch_roads.the_geom) from ch_roads,placename_region where st_contains(placename_region.the_geom,ch_roads.the_geom))

But it went wrong. wrong placenames updated in placename field. Please help me to solve this

share|improve this question

It doesn't work because that's not the proper way of making a UPDATE from a SELECT , You are doing something else...

Something like this should work, although I don't understand this part of the query:

haryana.the_geom in (select st_centroid(ch_roads.the_geom) ....)

or as I rephrased it:

st_centroid(ch_roads.the_geom) = haryana.the_geom

here is the full query:

Update haryana set placename = from placename_region,ch_roads where st_contains(placename_region.the_geom,ch_roads.the_geom) && st_centroid(ch_roads.the_geom) = haryana.the_geom;

share|improve this answer
Thanks.Its working – Sreesha Sep 25 '12 at 4:46

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.