I have two tables, both contain email address.
I need to return all rows in table 1 that do not have a matching email address in table 2.
For simplicity sake we can just say they both have two fields, name and email.
Asked
Active
Viewed 999 times
2

Xi Vix
- 1,381
- 6
- 24
- 43
-
isaace answered ... waiting for timer to expire to check the box – Xi Vix Aug 08 '17 at 20:16
3 Answers
0
select * from table1 where emailAddress not it (select email address from table2)

isaace
- 3,336
- 1
- 9
- 22
0
You can try LEFT JOIN with NULL in where clause. In LEFT JOIN, if table2 has no matching values, it will be represented by NULL.
SELECT * FROM Table1 LEFT JOIN Table2 ON Table1.email = Table2.email WHERE Table2.email IS NULL

Praveen E
- 926
- 8
- 14
0
SELECT
table_A.column_1,
table_A.column_2,
table_A.email
FROM table_A
WHERE table_A.email
NOT IN ( SELECT table_B.email FROM table_B )
An example with several columns from Table A.
Both, Table A and Table B have a column named "email".
Matching emails from Table B will be omitted in the query results.
( This question is similar to Mysql: Select rows from a table that are not in another )

Yoda - user264474
- 93
- 1
- 8