Search Postgresql Archives

Re: SQL delete and update at the same time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry, I don't know much about postgis at all. I assume you meant to have THEN 1 in your update statement as well.

I notice b.fid=l.fid and NOT b.fid=l.fid in the two clauses. How about separate update statements?


UPDATE linesegments l
set edited = 1
WHERE l.gid IN (SELECT li.gid FROM linesegments li, buffered as b WHERE ST_Contains(b.the_geom, li.the_geom) AND
                                            (l.edited = 0 OR l.edited = null) AND
                                            NOT b.fid=l.fid);
UPDATE linesegments l
set edited = 2
WHERE l.gid IN (SELECT li.gid FROM linesegments li, buffered as b WHERE ST_Contains(b.the_geom, li.the_geom) AND
                                            (l.edited = 0 OR l.edited = null) AND
                                            b.fid=l.fid);


Something like this (and similar for b.fid=l.fid) should be equivalent to the above as best I can figure. It might be more performant, but I don't know the internals well enough to say for sure.

UPDATE linesegments l
set edited = 1
FROM buffered as b
WHERE
l.gid = l.gid and ST_Contains(b.the_geom, li.the_geom) AND
                                            (l.edited = 0 OR l.edited = null) AND
                                            NOT b.fid=l.fid;

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux