Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WHERE with wildcards

Status
Not open for further replies.

CherylD

Programmer
May 1, 2001
107
CA
I'm using a where clause that checks a description field, and selects where that description is NOT like something. For some reason, this excludes all records whose description field is null.

EG.
WHERE sysdba.SALESORDERDETAIL.DESCRIPTION NOT LIKE '%Membership%'

If description = "something", the row is returned.
If description = "1998 Membership fees", the row is not returned.
If description = &quot;<NULL>&quot;, the row is not returned.

What can I do to get the 3rd case(description = <NULL>) to return the row?
 
hi,

u can add an or statemnet to ur SQL like this

WHERE (sysdba.SALESORDERDETAIL.DESCRIPTION NOT LIKE '%Membership%' or sysdba.SALESORDERDETAIL.DESCRIPTION is NULL)

Hope it helps

Sunil
 
The state of NULL is almost like a third boolean value ie, it is not True but is not False either - it is literally UNKNOWN.

Therefore to return NULL values in your query you need to do this:

Code:
WHERE column_name IS NOT LIKE '%membership%' OR column_name IS NULL
--James
 
Sorry - ignore the IS in the first statement:

Code:
WHERE column_name NOT LIKE '%membership%' OR column_name IS NULL
--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top