[postgis-users] Update field from expression

Birgit Laggner birgit.laggner at vti.bund.de
Fri Jan 28 04:19:09 PST 2011


  Hi Nicolas,

you're right - I've made this mistake very often myself...

If there can be only one polygon for each point where st_within turns 
true for (which I assume), then this form of the query may solve that 
problem:

UPDATE permit_sites p_s SET huc = giddy.h_gid FROM (SELECT p.gid p_gid, h.gid h_gid FROM permit_sites p inner join huc8 h on p.the_geom @ h.the_geom
  WHERE ST_Within(p.the_geom,h.the_geom)) AS giddy WHERE p_s.gid=giddy.p_gid;


I hope, I made no mistake...

Regards,

Birgit.


On 28.01.2011 10:55, Ture Pålsson wrote:
> 2011/1/28 Nicolas Ribot<nicolas.ribot at gmail.com>:
>
>> UPDATE permit_sites SET huc = giddy.gid FROM (SELECT h.gid FROM huc8 h,
>> permit_sites p WHERE ST_Within(p.the_geom,h.the_geom)) AS giddy;
> Let me ask a rhetorical question: Which row from the inner SELECT gets
> connected to which row of the table being updated?
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



More information about the postgis-users mailing list