Solved

Select from table A where not in table B

Posted on 2011-02-23
2
472 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

730 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