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
 General SQL Server Forums
 New to SQL Server Programming
 Only show data where join returns nothing

Author  Topic 

yawnzzzz
Starting Member

13 Posts

Posted - 2009-07-22 : 14:51:41
Hi,

I have products in one table and styles in another table. I want to find the products where there's no corresponding style.

This should get the list:
SELECT p.PRODUCT, s.STYLE FROM PRODUCTS p LEFT JOIN STYLES s on p.STYLE_ID = s.STYLE_ID


, but it's millions of lines long, so I'd like to just see the one's without a corresponding style.

I thought about:

WHERE s.STYLE = NULL


...but that returns nothing, so I'm not sure if everything is working correctly, or if that won't work.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-07-22 : 14:57:10
WHERE s.STYLE IS NULL

Jim
Go to Top of Page

yawnzzzz
Starting Member

13 Posts

Posted - 2009-07-22 : 14:59:43
Perfect! Thank you.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-07-22 : 15:39:30
Understand...

null in not equal to anything...even itself



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -