Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 9CF236323EC for ; Fri, 24 Apr 2009 11:32:11 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 79252-04 for ; Fri, 24 Apr 2009 11:32:09 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 4BEBE6321BE for ; Fri, 24 Apr 2009 11:32:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n3OEW8jk024330; Fri, 24 Apr 2009 10:32:08 -0400 (EDT) To: stayler@washoecounty.us cc: pgsql-sql@postgresql.org Subject: Re: varchar value comparisons not working? In-reply-to: <1240581570.21067.18.camel@shop.telecom.co.washoe.nv.us> References: <1240581570.21067.18.camel@shop.telecom.co.washoe.nv.us> Comments: In-reply-to Shawn Tayler message dated "Fri, 24 Apr 2009 06:59:30 -0700" Date: Fri, 24 Apr 2009 10:32:08 -0400 Message-ID: <24329.1240583528@sss.pgh.pa.us> From: Tom Lane 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: 200904/112 X-Sequence-Number: 32458 Shawn Tayler writes: > I run the following: > select sfd.lid as sflid,sd.lid as slid,sfd.serial from sfd,shawns_data > sd where sfd.serial = sd.serial_number order by sfd.lid; > the lid columns in both tables should be identical, but as you see in > this sample, they do differ: > sflid | slid | serial > -------+-------+---------- > 14056 | 14056 | 9614583 > 14057 | | 9614984 > 14058 | 14058 | 9614737 > 14059 | 14059 | 9614579 > 14060 | | 9614827 > 14061 | 14061 | 9614726 > 14062 | 14062 | 9614966 > 14063 | 14063 | 9615079 > So running this query: > select count(*) from sfd,shawns_data sd where sfd.serial = sd.serial_number and sfd.lid != sd.lid; > I should show some rows that do not match, at least 2 (there are more than shown). > But instead I get this: > count > ------- > 0 > (1 row) Probably those "blank" values of slid are really NULLs. A NULL isn't "equal to" something else, but it isn't "unequal" either. You could use IS DISTINCT FROM instead of != in your second query. regards, tom lane