[postgis-users] avoid duplicates with lateral auto join

Darafei "Komяpa" Praliaskouski me at komzpa.net
Sun May 28 07:30:21 PDT 2017


Add something like

where o.ctid < t1.ctid

to the inner query.
Also, the query doesn't need to be lateral join,

select
a.name,
b.name
from t1 a, t1 b
where ST_Intersects(a.geom, b.geom)
and a.ctid < b.ctid;

should work the same.

вс, 28 мая 2017 г. в 15:18, Olivier Leprêtre <o.lepretre at gmail.com>:

> Hi,
>
>
>
> Doing a lateral auto join return cross results like A,B and B,A. Is there
> a simple trick to avoid that ?
>
>
>
> To explain : in such query
>
>
>
> select o.name,nam1 from
>
> t1 o,
>
> lateral (select o.name,t1.nam nam1 from t1
>
> where st_overlaps(o.geom,t1.geom)) lat
>
> order by o.name
>
>
>
> I get results like
>
>
>
> polygon1       polygon2
>
> polygon2       polygon1
>
>
>
> because polygon1 overlap polygon2 and conversely.
>
>
>
> how could I get only one of those pairs ?
>
>
>
> Thanks,
>
>
>
> Olivier
>
>
>
>
>
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> Garanti
> sans virus. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
> <#m_7124570515368415938_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20170528/4b7b5daa/attachment.html>


More information about the postgis-users mailing list