Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 478
  • Last Modified:

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
0
SheppardDigital
Asked:
SheppardDigital
1 Solution
 
Kent OlsenData 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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now