From: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: What's wrong with this query? |
Date: | 2009-06-22 08:08:14 |
Message-ID: | h1ne5e$bpk$1@ger.gmane.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Albe Laurenz, 22.06.2009 09:52:
> Sorry to be nitpicking, but maybe in that case it adds to clarity:
>
> A comparison with NULL does not return FALSE, but "undefined" or NULL.
>
> Try to run the following queries:
>
> SELECT 1 = 2;
> and
> SELECT 1 = NULL;
>
> and observe the different result.
>
> In the context of the original question this difference does not matter,
> because a comparison is considered successful only if it returns TRUE.
>
> But I think this way it becomes clearer *why* neither = nor != will
> succeed for a NULL (= undefined) value: if you don't know which value
> a certain thing has, you can neither say that it is equal to 1 nor
> that it is not equal to 1.
Good points :)
Thanks for the clarification!
I recently saw a blog talking about interview questions. One of them was:
Under which circumstances does the following query *not* return all rows
SELECT *
FROM the_table
WHERE some_column = some_column;
boils down to the same behaviour...
Regards
Thomas
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2009-06-22 09:40:08 | Re: temp tables, sessions, pgpool and disk |
Previous Message | Ivan Sergio Borgonovo | 2009-06-22 07:53:59 | Re: temp tables, sessions, pgpool and disk |