From: DownLoad X <x_download@hotmail.com>
To: bruno@wolff.to
Cc: pgsql-sql@postgresql.org
Subject: Re: Searching for results with an unknown amount of data
Date: Wed, 07 Sep 2005 22:54:24 +0100
Message-ID: <BAY101-F10FD61CD14D1A8A22D9D04FCA60@phx.gbl> (raw)
In-Reply-To: <20050906144541.GA30161@wolff.to>
> > Now, I want to find all objects that have at most properties 1,2,3, say
>(so
> > something with (1,2) is okay, as is (1,2,3)). I can't see a way to do
>this
> > -- can anyone help?
>
>It sounds like you are trying to find all objects that do not have any
>properties outside of a specific list. One way to get that list is:
That's exactly right.
>
>SELECT a_id
> FROM a
> WHERE
> NOT EXISTS
> (SELECT 1
> FROM b
> WHERE
> b.a_id = a.a_id
> AND
> b.property NOT IN (1, 2, 3)
> )
>;
Yupp, this appears to do it! The 'double negation' is very clever.
Thanks a lot,
DL
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: x_download@hotmail.com, bruno@wolff.to
Subject: Re: Searching for results with an unknown amount of data
In-Reply-To: <BAY101-F10FD61CD14D1A8A22D9D04FCA60@phx.gbl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox