X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 17D65D1BA1A for ; Sat, 23 Aug 2003 22:31:42 -0300 (ADT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 86818-04 for ; Sat, 23 Aug 2003 22:31:13 -0300 (ADT) Received: from frmug.org (frmug-gw.frmug.org [193.56.58.252]) by svr1.postgresql.org (Postfix) with ESMTP id B2118D1B550 for ; Sat, 23 Aug 2003 22:31:09 -0300 (ADT) Received: from frmug.org (localhost [127.0.0.1]) by frmug.org (8.12.9/8.11.3/frmug-2.7/nospam) with ESMTP id h7O1Uug2073874 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified NO) for ; Sun, 24 Aug 2003 03:30:57 +0200 (CEST) (envelope-from pgsql-sql@phoe.frmug.org) Received: (from uucp@localhost) by frmug.org (8.12.9/8.12.9/Submit) with UUCP id h7O1UuvP073873 for pgsql-sql@postgresql.org; Sun, 24 Aug 2003 03:30:56 +0200 (CEST) Received: (from elrond@localhost) by memo.frmug.org (8.11.6/8.11.6) id h7O1SF332587 for pgsql-sql@postgresql.org; Sun, 24 Aug 2003 03:28:15 +0200 (CEST) (envelope-from pgsql-sql@phoe.frmug.org) X-Authentication-Warning: memo.frmug.org: elrond set sender to pgsql-sql@phoe.frmug.org using -f Date: Sun, 24 Aug 2003 03:28:15 +0200 From: Bertrand Petit To: PostgreSQL-sql Subject: Equality operators on NULL values Message-ID: <20030824032815.A32448@memo.frmug.org> Mail-Followup-To: PostgreSQL-sql Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/287 X-Sequence-Number: 14903 (in)Equality operators evaluates to NULL when any of their arguments are NULL as summarized bellow. NULL=NULL ==> NULL 1=NULL ==> NULL 1=1 ==> t 1=2 ==> f I have a case where I need to delete rows from table A for records that are designated in table B. One of the joined colum can have NULL values. Therefore I need an operator behaving as follows: NULL=NULL ==> t 1=NULL ==> NULL (or anything else as long as it is not t) 1=1 ==> t 1=2 ==> f I replaced the use of the = operator with this expression: nullif(tabA.col_with_nulls, tabB.col_with_nulls) IS NULL It works correctly but the intent is not that clear. Is there a stock replacement operator that would behave like the second truth table? Regards, Bertrand. -- %!PS 297.6 420.9 translate 90 rotate 0 setgray gsave 0 1 1{pop 0 180 moveto 100 180 170 100 170 -10 curveto 180 -9 180 -9 190 -10 curveto 190 100 100 180 0 180 curveto fill 180 rotate}for grestore/Bookman-LightItalic findfont 240 scalefont setfont -151.536392 -63.7998886 moveto (bp)show showpage