Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql opposite of inner join

Tags:

sql

mysql

I want to contact my users via email using my database. I want to make sure that I don't accidentally contact the same user twice. For that, I have a table that tracks who got contacted and when.

When I do my MYSQL query I want to select emails from the the email table and make sure none of those entries exists in the contacted table.

To phrase it in a sentence: select email from Email_Table if they are not in Contacted_Table

Perhaps there is a completely different approach. I am open to all suggestions :)Thank you :)

like image 247
salmane Avatar asked Jan 03 '11 14:01

salmane


People also ask

What is opposite of inner join?

If you consider an inner join as the rows of two tables that meet a certain condition, then the opposite would be the rows in either table that don't.

Is an outer join the opposite of an inner join?

The biggest difference between an INNER JOIN and an OUTER JOIN is that the inner join will keep only the information from both tables that's related to each other (in the resulting table). An Outer Join, on the other hand, will also keep information that is not related to the other table in the resulting table.

What can I use instead of an inner join?

Oracle recommend you use ANSI joins, at least for outer joins.

What is inner join and outer join?

Different Types of SQL JOINs Here are the different types of the JOINs in SQL: (INNER) JOIN : Returns records that have matching values in both tables. LEFT (OUTER) JOIN : Returns all records from the left table, and the matched records from the right table.


1 Answers

Try this

SELECT email FROM email_table e  LEFT JOIN contacted_table c ON e.email = c.email WHERE c.email IS NULL 
like image 194
German Rumm Avatar answered Sep 20 '22 14:09

German Rumm