Select from table A where not in table B

I'm trying to select rows from table A where there isn't a corresponding row in table B

I'm trying this but it's not returning any results at all. Table A has 30 records and at the minute table B has none, so it should return every row in table A.

SELECT *
FROM leads
LEFT JOIN lead_activity ON leads.id = lead_activity.lead_id
WHERE lead_activity.id =  ''
LIMIT 0 , 30
SheppardDigitalAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Kent OlsenConnect With a Mentor Data Warehouse Architect / DBACommented:
Hi Sheppard,

Close, very close.  :)  Test for null instead of space.

  WHERE lead_activity.id is NULL


Good Luck,
Kent
0
 
SheppardDigitalAuthor Commented:
Thanks, I had tried WHERE lead_activity.id = NULL and it didnt work, but now I know it needs to be 'IS'
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.