Jump to content

Recommended Posts

SELECT
   a.email
FROM a
LEFT JOIN b ON b.email=a.email
WHERE
  b.email IS NULL

 

That will join to table b matching up rows by the email field.  If no row exists in table b matching table a's email value, then all the fields in b will be NULL for that record.  The WHERE condition then filters the result to only the rows where the b.email field is null, meaning you only get the email's from a with no match in b.

 

Hi,

 

If I wanted to join on another table would the query be something like this:

 

SELECT
  a.email
FROM a
LEFT JOIN b ON b.email=a.email
LEFT JOIN c ON c.email=a.email
WHERE
 b.email IS NULL AND c.email IS NULL

 

I tried this and its not quite right. I would only want to return records from table a if they are not in b and c.

 

Any further suggestions would be appreciated as always.

 

Thank you :)

According to the WHERE clause, you've specifically asked for e-mails that were not in both table B and table C. Meaning if the e-mail is in either of those tables, it would be skipped. If you want e-mails that are missing from only one of those table, replace the AND with an OR.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.