Re: Difference between = and IN
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 02/07/05
- Next message: Andy: "Re: Difference between = and IN"
- Previous message: Andy: "Re: Difference between = and IN"
- In reply to: Andy: "Re: Difference between = and IN"
- Next in thread: Andy: "Re: Difference between = and IN"
- Reply: Andy: "Re: Difference between = and IN"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 07 Feb 2005 15:41:29 +0100
On Mon, 7 Feb 2005 06:17:04 -0800, Andy wrote:
>Hi Hugo
>
>Thanks for this - I wasn't aware there was an issue with IN/NOT IN and
>Nulls! I was under the impression that Nulls would just be excluded from the
>results.
Hi Andy,
That's what most people think - but it's not true.
WHERE Column1 NOT IN (1, 2, NULL)
will (as per the ANSI-standard SQL-92) be equivalent to
WHERE Column1 <> 1
AND Column1 <> 2
AND Column1 <> NULL
And since Column1 <> NULL is neither "true" nor "false", but "unknown",
this expression can only evaulate to "false" (as a result of "false" AND
"unknown") or "unknown" (as a result of "true" and "unknown").
Consider it like this - would you be willing to bet a significant amount
that the 40 is NOT IN (your age, George W. Bush's age, my age)?
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Andy: "Re: Difference between = and IN"
- Previous message: Andy: "Re: Difference between = and IN"
- In reply to: Andy: "Re: Difference between = and IN"
- Next in thread: Andy: "Re: Difference between = and IN"
- Reply: Andy: "Re: Difference between = and IN"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|