Re: select from one table with help of another table

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: paul(dot)malm(at)lfv(dot)se, pgsql-novice(at)postgresql(dot)org
Subject: Re: select from one table with help of another table
Date: 2020-06-16 12:03:33
Message-ID: 1e61913d6482fece1d2564181785b2b0627b011b.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tue, 2020-06-16 at 08:37 +0000, paul(dot)malm(at)lfv(dot)se wrote:
> I’m trying to get the fid (integer) of objects in table line where the geometry (postgis) is inside another geometry from another table (polygon),
> But I would not like to get the objects with the highest fid inside the polygons of table buffered.
> I’ve tried this:
>
> SELECT fid FROM
> "line" USING “polugon” AS b WHERE
> ST_Contains(b.geom, "line".geom) AND "line".fid NOT IN (SELECT MAX("line".fid)
> );
>
> It complains about “USING” in line 2.
> Anyone who knows how I should do it instead?

What if a "line" is contained in more than one "polugon", and
in one of these it has the highest "fid", but not in the others?

Should that be included in the results?

Yours,
Laurenz Albe

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message David G. Johnston 2020-06-16 15:05:32 Re: select from one table with help of another table
Previous Message paul.malm 2020-06-16 08:37:54 select from one table with help of another table