Solved

Select from table A where not in table B

Posted on 2011-02-23
2
473 Views
Last Modified: 2012-05-11
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
Comment
Question by:SheppardDigital
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 45

Accepted Solution

by:
Kent Olsen earned 500 total points
ID: 34964502
Hi Sheppard,

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

  WHERE lead_activity.id is NULL


Good Luck,
Kent
0
 

Author Closing Comment

by:SheppardDigital
ID: 34964523
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question