Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 493662E006D for ; Tue, 1 Apr 2008 13:44:00 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 94547-03-2 for ; Tue, 1 Apr 2008 13:43:48 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from rn-out-0910.google.com (rn-out-0910.google.com [64.233.170.184]) by developer.postgresql.org (Postfix) with ESMTP id 8483C2E0070 for ; Tue, 1 Apr 2008 13:43:49 -0300 (ADT) Received: by rn-out-0910.google.com with SMTP id s46so1215502rnb.3 for ; Tue, 01 Apr 2008 09:43:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=oRAuaUtdM34I0O2N0KQya52DFkHGDSBD+gfu39ycP3c=; b=sWkALlNWMgBlhD+fDSgu2ruJahiRIDsvT2NfBcTlPl02Lo7z78wdInfgZ90iPYzud3PJFw7RM9N9+hYmmhOo6wQSSqKDiB7YcMlcE2xn/1yALMXR0/rDPVrkuz3ENTsC6d7tlYEe75/xIj9H8KMpDU28G/xHQ2qj+5PGbTa+eVY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=f/NEBqJNhtuI9uwqx9tUZrQvXiZjC1fN2S4lR5n4vkM+vevQjPLwi534PSr0qYn7Qp/6ILRL4UZJ5eKEJpu/7VHQQGACoQcD4QUDZU3n+9PbyNbv7ugpm2xG8pLQ9dLN2F9lZ7D6HFfCqpq66TPyg25SP75h6EborTrPKmYiBO4= Received: by 10.114.38.2 with SMTP id l2mr12792834wal.69.1207068227561; Tue, 01 Apr 2008 09:43:47 -0700 (PDT) Received: by 10.114.201.13 with HTTP; Tue, 1 Apr 2008 09:43:47 -0700 (PDT) Message-ID: Date: Tue, 1 Apr 2008 18:43:47 +0200 From: "Raphael Bauduin" To: "Stephan Szabo" Subject: Re: difference between EXCEPT and NOT IN? Cc: pgsql-sql@postgresql.org In-Reply-To: <20080401085733.F16796@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080401085733.F16796@megazone.bigpanda.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200804/4 X-Sequence-Number: 30543 On Tue, Apr 1, 2008 at 6:04 PM, Stephan Szabo wrote: > On Tue, 1 Apr 2008, Raphael Bauduin wrote: > > > The 2 following statements don't give the same result. I expected the > > second ti give the exact same result as the first one. > > If any entree_id can be NULL they aren't defined to give the same result. > > EXCEPT is defined in terms of duplicates based on distinctness, and for > example (1 is distinct from 1) is false, (1 is distinct from NULL) is true > and (NULL is distinct from NULL) if false. > > NOT IN is defined in terms of equality, and for example, (1=1) is true, > (1=NULL) is unknown and (NULL=NULL) is unknown. > My problem came from 2 entries in the table postes that had an entree_id NULL Thanks for your fast answer, it has helped me spot the problem! Raph -- Web database: http://www.myowndb.com Free Software Developers Meeting: http://www.fosdem.org