How do I select items from 1 table that are not in another?

Hello everybody,
I am running a mail program, and it crashed in mid session. So I need to restart it but only using email addresses that the email was not sent to.

I have one table of email addresses, which has the fields

id,email, country

and another, called logs

id, email, date

How do I select all the emails in the first table that are not in the second?

Thanks in advance.

try this

select email from addresses where
email not in (select email from logs);

alternatively,


SELECT addresses.email
  FROM addresses
LEFT OUTER
  JOIN logs
    ON logs.email = addresses.email
 WHERE logs.email IS NULL

:slight_smile:

Cool guys, thanks :slight_smile: