Re: NULL

From: Laconic2 <laconic2_at_comcast.net>
Date: Mon, 4 Oct 2004 09:43:38 -0400
Message-ID: <xtmdnfbIZo8DzvzcRVn-sA_at_comcast.com>


I love talking about nothing!

Part of the problem is the way we mentally parse "NOT x = y"

Consider these three queries:

select * from employees
where middle_initial = 'X'
or not middle_initial = 'X'

select * from employees
where middle_initial = 'X'
or middle_initial <> 'X'

select * from employees
where employee_id in (select employee_id

        from employees where middle_initial = 'X') or employee_id not in (select employee_id

       from employees where middle_initial = 'X')

At first glance it looks like these three should always return the same answers.

For all employees that have a middle initial that of 'X', they will be included. For all employees that have a middle initial that's something other than 'X', they will be included.

But what about those who have no middle intial, at least as far as the database knows? In other words where middle_initial is NULL?

I think it's obvious that the second query will omit them, but the third query will include them. What about the first query? Received on Mon Oct 04 2004 - 15:43:38 CEST

Original text of this message