Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: id <> '2'

Re: id <> '2'

From: Malcolm Dew-Jones <yf110_at_vtn1.victoria.tc.ca>
Date: 21 Sep 2005 15:12:30 -0700
Message-ID: <4331dace@news.victoria.tc.ca>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US