Re: Searching for results with an unknown amount of data

From: "DownLoad X" <x_download(at)hotmail(dot)com>
To: bruno(at)wolff(dot)to
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Searching for results with an unknown amount of data
Date: 2005-09-07 21:54:24
Message-ID: BAY101-F10FD61CD14D1A8A22D9D04FCA60@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> > 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Roger Tannous 2005-09-07 23:08:54 Re: column names, types, properties for a table
Previous Message Philip Hallstrom 2005-09-07 21:38:31 Re: column names, types, properties for a table