[postgis-users] RE : Need help with update table from a select query

Hugues François hugues.francois at irstea.fr
Fri May 24 11:21:31 PDT 2013


Hello,

You should try :

update nodes a
set outline_id = b.outline_id
from outlines b
where st_contains(b.geom, a.geom)

Hugues.


-------- Message d'origine--------
De: postgis-users-bounces at lists.osgeo.org de la part de Clifford Snow
Date: ven. 24/05/2013 19:24
À: PostGIS Users Discussion
Objet : [postgis-users] Need help with update table from a select query
 
I need some help figuring out how to update a table. I'm trying to get the
polygon id that a node resides in. I have two tables, one of outlines and
another with nodes. I want to add the id of the outline the node is
contained in to the node.

my thought was this query:
update nodes set outline_id = (select outline_id from oulines, nodes where
st_contains(outline.geom, nodes,geom))

But this query returns more than one row. What am I doing wrong?

Thanks
-- 
Clifford

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 3149 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130524/3f74a7a6/attachment.bin>


More information about the postgis-users mailing list