Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Criteria on NULL value

Author  Topic 

Stephanie Baroux
Starting Member

3 Posts

Posted - 2004-07-13 : 09:13:34
Hello

I try to run the following query:

SELECT id1,id2
from t1, t2
where t1.id1 *= t2.id2
and t2.id2 is NULL;

The last criteria "t2.id2 is null" doesn't work.

Details of data:

SELECT id1,id2
from t1, t2
where t1.id1 *= t2.id2

Result
> t1 t2
111 111
222 NULL
333 333
444 444
555 NULL


SELECT id1,id2
from t1, t2
where t1.id1 *= t2.id2
and t2.id2 is null;

Result
> t1 t2
111 NULL
222 NULL
333 NULL
444 NULL
555 NULL

Result expected:
> t1 t2
222 NULL
555 NULL



If somebody can help me to gix this query, it would be very helpful

Thanks

Stephanie

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-07-13 : 09:15:03
SELECT
id1,id2
from t1
Left Join t2
on t1.id1 = t2.id2
Where t2.id2 is NULL

Corey
Go to Top of Page
   

- Advertisement -