Solved

Select from table A where not in table B

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can i make performance tuning to my sql query? 6 54
Question about DB Schema 27 61
SYbase 4 36
MySQL Memory Keeps Increasing 4 47
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Creating and Managing Databases with phpMyAdmin in cPanel.
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…

839 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