Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlAJZ-0002E9-4a for pgsql-novice@arkaria.postgresql.org; Tue, 16 Jun 2020 12:03:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jlAJX-00087Y-LO for pgsql-novice@arkaria.postgresql.org; Tue, 16 Jun 2020 12:03:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlAJX-00087R-At for pgsql-novice@lists.postgresql.org; Tue, 16 Jun 2020 12:03:39 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jlAJT-0005SK-Ic for pgsql-novice@postgresql.org; Tue, 16 Jun 2020 12:03:38 +0000 Received: by mail-ed1-x532.google.com with SMTP id w7so14076087edt.1 for ; Tue, 16 Jun 2020 05:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=X0Dc61FQ9WBnC3P3xbjTBbHqFySbLd+UKAh1mA7GudI=; b=OsIbygWTDWnyKipoWmOt9/e7JWMSKN+0631p7QzcgHZVAFJCdytfwA26dpcpojdu8Q E7hXe1blIOdOEOK38spCxmbCWqgqv+jzShlpFELv3uA6NoD5s3WB+7l2FIPj87qNE9lo FcPdDaXiAyS2QYJ5GZ91JE5EtK/jqd/GgzAisYUeCzfABaYRfPY/LyPvSXROl9UIhEJR g+TABm4sa9nuctMz/rbv/DtXTZizXoHEGwZAa8gvVgTTmaXGRuJj4aZEOqEiyGObJDr3 w/KmCgbP4ld1eHLNqDPXOqNop+pUkgmtACwq5xx3Wjq36lEhhUZbrF6NiUhkaiO3eMBK 6dDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=X0Dc61FQ9WBnC3P3xbjTBbHqFySbLd+UKAh1mA7GudI=; b=U6iKjbJct8gFrXYwCUNK/2ZUm5qKcZUiqownBqklEMvAyrvIItkgR8JFFjWx4KkBoO HwzhGLjd/7szcBTqDORBSBm8+wbtWYFseVsMZKOq3yRDixONbQAcUuzvlC9GHmQ2zuwB YPu3pEu69PJoHGAtdy+gSfKmDY+x/dJuSiCWIAp98R3NKJF13Xd7czJdoPiGVFge4+CJ kHe7FkRbmI9xdbMaNk4if3+3ygs11RsSX8QqHtHBwJD96mdW6A0wJVCu9ivNL2cfC6gc fchr+JkGT61tr+Q8c80dNDcrfkIhU+MkG9+qtJCFw7/0yQ21W9XxYwgSfV2EwSy0JoPx chBA== X-Gm-Message-State: AOAM5306uS9Wmz8xvw8RleKR26JuhH39+VF1F6f2fesVJbwi7JKg2Tzx JYeA8K3Ki/TXb02oW0OgciOzTBeNkwr2dA== X-Google-Smtp-Source: ABdhPJzwjpbdQvjU1/TTGdYzUDHKMXYfzdDcU09PdIKbjytqcJotArIRySMA+ifzDDIaHiehjjR/dg== X-Received: by 2002:aa7:d613:: with SMTP id c19mr2158319edr.321.1592309014287; Tue, 16 Jun 2020 05:03:34 -0700 (PDT) Received: from localhost.localdomain (217-149-170-104.nat.highway.telekom.at. [217.149.170.104]) by smtp.gmail.com with ESMTPSA id p13sm9918137edq.50.2020.06.16.05.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 05:03:33 -0700 (PDT) Message-ID: <1e61913d6482fece1d2564181785b2b0627b011b.camel@cybertec.at> Subject: Re: select from one table with help of another table From: Laurenz Albe To: paul.malm@lfv.se, pgsql-novice@postgresql.org Date: Tue, 16 Jun 2020 14:03:33 +0200 In-Reply-To: <83202aff46a942fd922fdb7457442b37@lfv.se> References: <83202aff46a942fd922fdb7457442b37@lfv.se> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, 2020-06-16 at 08:37 +0000, paul.malm@lfv.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