From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | stayler(at)washoecounty(dot)us |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: varchar value comparisons not working? |
Date: | 2009-04-24 14:32:08 |
Message-ID: | 24329.1240583528@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Shawn Tayler <stayler(at)washoecounty(dot)us> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Ruprecht | 2009-04-25 02:04:54 | Variable number or arguments to a function possible? |
Previous Message | Shawn Tayler | 2009-04-24 13:59:30 | varchar value comparisons not working? |