Re: Strange result with select/not null/OR

From: Avi Schwartz <avi(at)CFFtechnologies(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Strange result with select/not null/OR
Date: 2003-06-10 02:12:46
Message-ID: 0736CE7A-9AE9-11D7-AD34-000393AE5044@CFFtechnologies.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

That is because '' is not equal to null and therefore the first part
(sp_link is not null) satisfies the requirement.

Avi

On Monday, Jun 9, 2003, at 14:48 America/Chicago, Fernando Papa wrote:

>
> Hi all!
>
> I get a strange result with this query:
>
> SELECT count(*)
> FROM CONT_CAT
> WHERE id_instal = 2
> and id_cat = 2
> and (sp_link IS NOT NULL OR sp_link <> '')
>
>
> I have one row with an empty value ('') on sp_link, so, when I execute
> the query expect 0 on the result.
> I don't know why the result is 1.
> If I only put the last part ("sp_link <> ''") everithing goes ok.
> But I need to check both conditions, IF is null and IF is empty. And I
> can't understand why doesn't work.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vincent Hikida 2003-06-10 02:22:20 Re: Strange result with select/not null/OR
Previous Message Martijn van Oosterhout 2003-06-10 01:56:24 Re: parse errors when connecting to remote host