pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: DownLoad X <x_download@hotmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Searching for results with an unknown amount of data
Date: Tue, 6 Sep 2005 09:45:41 -0500
Message-ID: <20050906144541.GA30161@wolff.to> (raw)
In-Reply-To: <BAY101-F2270E5778C3FE6208B3501FCA30@phx.gbl>
References: <BAY101-F2270E5778C3FE6208B3501FCA30@phx.gbl>

On Fri, Sep 02, 2005 at 20:40:24 +0100,
  DownLoad X <x_download@hotmail.com> wrote:
> 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:

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

This doesn't take into account the semantics of nulls. If your data can have
nulls in it, then you need to decide precisely what you want and adjust
the query appropiately.



view thread (5+ messages)  latest in thread

Message-ID: <20050906144541.GA30161@wolff.to>
Permalink:  ../20050906144541.GA30161@wolff.to/
Also on:    postgresql.org/message-id/20050906144541.GA30161@wolff.to

 · 

reply

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: bruno@wolff.to, x_download@hotmail.com
  Subject: Re: Searching for results with an unknown amount of data
  In-Reply-To: <20050906144541.GA30161@wolff.to>

* 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