From: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | seijin(at)gmail(dot)com |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: String Comparison and NULL |
Date: | 2008-04-29 11:42:13 |
Message-ID: | 162867790804290442v69366b12o547d1e39d211137@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello
2008/4/28 <seijin(at)gmail(dot)com>:
> Hi,
>
> I'm fairly new to PG and databases in general so this may very well be
> a problem in my thought process.
>
> If I have a simple table with an ID (integer) and Animal (text) like
> this...
>
> 1 Dog
> 2 Cat
> 3 NULL
> 4 Horse
> 5 Pig
> 6 Cat
> 7 Cat
>
> ... and I do something like "select id where animal <> 'Cat';" then
> shouldn't 1, 3, 4 and 5 be picked? As it is I only get 1, 4 and 5.
> NULL is not 'Cat'. I realize that if I were testing for NULL itself I
> would use IS or IS NOT but this...? I'm a little confused.
>
In this case use operator IS DISTINCT FROM
select id where animal IS DISTINCT FROM 'Cat';
Regards
Pavel Stehule
> Thanks!
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tatsuo Ishii | 2008-04-29 11:58:59 | Re: Multibyte (Japanese Character) Sorting |
Previous Message | Oleg Malyovaniy | 2008-04-29 10:30:04 | Delete xml node from xml-document |