Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: id <> '2'
mike (hillmw_at_charter.net) wrote:
: I have a field defined as follows:
: id integer
: This field normally has some value in it 1,2,3,4, but it can be null.
: For example, say I have 10 records, and 5 records have values
: 1,2,3,4,5, but the other 5 are null
: If I do a select like:
: select *
: from mytable
: where id='2'
: I get 1 record.
: If I do a select like:
: select *
: from mytable
: where id<>'2'
: I get 4 records, but shouldn't I be getting 9 records?
No, only 4 of the records have an id with a value that is known to be different than 2. The NULL entries represent values that are not known, and therefore might be equal to 2 - you just can't say for sure.
E.g. If you asked me to send you books about Oracle, would you expect to also get books about other topics whenever I had a book and didn't understand what it was about?
: How would i change my select to get the 9 records?
Read up on "IS NOT NULL".
-- This programmer available for rent.Received on Wed Sep 21 2005 - 17:12:30 CDT
![]() |
![]() |