Home » SQL & PL/SQL » SQL & PL/SQL » select query with date = null??
select query with date = null?? [message #193105] |
Thu, 14 September 2006 22:22  |
pcgame4u
Messages: 14 Registered: July 2006
|
Junior Member |
|
|
My query below is not working, is there any suggestion?
The type of ADATE is DATE
select ADATE from testing where ADATE = NULL;
the query run ok, but it can't select the record that have no value in this column.
Thanks all of you on the help.
|
|
|
|
|
Re: select query with date = null?? [message #193111 is a reply to message #193105] |
Thu, 14 September 2006 22:36   |
shoblock
Messages: 325 Registered: April 2004
|
Senior Member |
|
|
a null is a null, of course of course, and nothing can be compared to a null of course, unless of course the clause is the famous "IS NULL" (kinda lost the tempo at the end there)
read the docs. NULL is UNKNOWN. Unknown is therefore never equal to, or unequal to, anything, including another null. that's why you can use either IS NULL or the NVL function.
returns no rows ever, because where clause never evaluates to TRUE:
select ADATE from testing where ADATE = NULL;
select ADATE from testing where ADATE <> NULL;
returns the rows you want:
select ADATE from testing where ADATE IS NULL;
select ADATE from testing where nvl(ADATE, trunc(sysdate-1000000) ) = trunc(sysdate-1000000);
returns the other rows:
select ADATE from testing where ADATE IS NOT NULL;
select ADATE from testing where nvl(ADATE, trunc(sysdate-1000000) ) <> trunc(sysdate-1000000);
|
|
|
|
Goto Forum:
Current Time: Tue Apr 29 06:48:45 CDT 2025
|