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

Home -> Community -> Usenet -> c.d.o.server -> Re: How to query an empty field?

Re: How to query an empty field?

From: Daniel Morgan <damorgan_at_x.washington.edu>
Date: Sat, 15 Nov 2003 15:15:16 -0800
Message-ID: <1068938139.175793@yasure>


Tom Miskiewicz wrote:

> Hi!
>
> I wrote a query that uses a empty field in the where clause, but it doesn't
> deliver the expected result.
>
> SELECT count(1) FROM mytable WHERE testfield1 = 2 and testfield2 = NULL;
>
> testfield2 is a NUMBER(15);
>
>
> Thanks
> Tom
>
>

Nothing anywhere in Oracle ever equals NULL. Nor does anything in Oracle ever NOT equal NULL. Try these:

SELECT COUNT(*)
FROM all_objects
WHERE NULL = NULL; SELECT COUNT(*)
FROM all_objects
WHERE NULL <> NULL;

As Chris says ... you must use IS or IS NOT.

-- 
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Sat Nov 15 2003 - 17:15:16 CST

Original text of this message

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