X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7948B3A58B7 for ; Thu, 2 Dec 2004 16:43:01 +0000 (GMT) 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 09513-09 for ; Thu, 2 Dec 2004 16:42:41 +0000 (GMT) Received: from www.postgresql.com (unknown [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id D54913A5803 for ; Thu, 2 Dec 2004 16:41:42 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) by www.postgresql.com (Postfix) with ESMTP id 4B50673925E for ; Thu, 2 Dec 2004 10:08:55 +0000 (GMT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 5167031921; Thu, 2 Dec 2004 11:08:26 +0100 (MET) From: Andrew - Supernews X-Newsgroups: pgsql.sql Subject: Re: find the "missing" rows Date: Thu, 02 Dec 2004 10:07:52 -0000 Organization: http://www.supernews.com - all your nntp are belong to us Message-ID: References: <33080.67.87.27.161.1101915810.squirrel@www.ke5in.com> <28993.1101952391@sss.pgh.pa.us> Reply-To: andrew@supernews.com User-Agent: slrn/0.9.8.0 (FreeBSD) X-Complaints-To: abuse@supernews.com Lines: 22 To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200412/27 X-Sequence-Number: 19647 On 2004-12-02, Tom Lane wrote: > "Kevin B." writes: >> Select a.i, b.i >> from t as a >> left join t as b on a.i = b.i >> where a.n = 'a' and b.n = 'b' and b.i is null > > This can't succeed since the b.n = 'b' condition is guaranteed to fail > when b.* is nulled out ... You can make it work by moving parts of the condition into the explicit join clause: select a.i from t as a left join t as b on a.n='a' and b.n='b' and a.i=b.i where a.n='a' and b.i is null; (notice you still need the check on a.n='a' outside the join condition) -- Andrew, Supernews http://www.supernews.com - individual and corporate NNTP services