X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B2355D8633 for ; Tue, 6 Sep 2005 11:45:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82363-05 for ; Tue, 6 Sep 2005 14:45:35 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id 8EE4AD85A3 for ; Tue, 6 Sep 2005 11:45:36 -0300 (ADT) Received: (qmail 31293 invoked by uid 500); 6 Sep 2005 14:45:41 -0000 Date: Tue, 6 Sep 2005 09:45:41 -0500 From: Bruno Wolff III To: DownLoad X Cc: pgsql-sql@postgresql.org Subject: Re: Searching for results with an unknown amount of data Message-ID: <20050906144541.GA30161@wolff.to> Mail-Followup-To: Bruno Wolff III , DownLoad X , pgsql-sql@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200509/60 X-Sequence-Number: 22607 On Fri, Sep 02, 2005 at 20:40:24 +0100, DownLoad X 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.