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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem comparing 2 fields with null values

Status
Not open for further replies.

newtechy

Programmer
Sep 23, 2002
22
0
0
US
I've created a query against the following table:

Table1:
fld1 fld2
row1 2 2
row2 <null> <null>
row3 1 2


The query:
Select * from table1 where fld1 = fld2 or (fld1 is null and fld2 is null)

My results set contains row1 but not row2. It appears that the query is ignoring row2 because both fld1 and fld2 have null values. Is there an alternate query I can use to include row2 in the results set?? Please advise
 
I can't find anything wrong with your query, it works on my test database.
 
Try this

Select * from table1 where Isnull(fld1,'') = Isnull(fld2,'')


Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top