Re: Strange query problem...

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Scott Whitney" <swhitney(at)journyx(dot)com>, <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Strange query problem...
Date: 2009-01-28 18:05:20
Message-ID: 49804A00.EE98.0025.0@wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

>>> "Scott Whitney" <swhitney(at)journyx(dot)com> wrote:
> Um. How is this possible?

> mydb=# select * from time_recs where id_time_rec not in (select
> id_time_rec from punch_time_recs);

> (0 rows)

> Table "public.punch_time_recs"
> Column | Type | Modifiers

>
-------------------+------------------------+-------------------------------

> id_time_rec | character varying(38) |

The column in punch_time_recs is null capable. Try using NOT EXISTS.

The SQL spec requires the NOT IN to be the equivalent of a "not
equals" test for all entries, and you can't say that any given value
is not equal to NULL, since NULL can mean that there is a value but
you don't know it. The semantics of NOT EXISTS are subtly different
here -- it means there aren't any rows known to have the value.

-Kevin

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Whitney 2009-01-28 18:21:35 Re: Strange query problem...
Previous Message Scott Whitney 2009-01-28 17:49:43 Strange query problem...