0

I have a query which works but am wondering if there is a better way to rewrite it at all.

The query is to find any email address in table1 that are missing from table2.

The MYSQL query is:

select
c.companyname
FROM table1 t1
JOIN table2 t2  on ( t2.hash = t1.recipient)
JOIN table3 t3  on (t3.hash = t1.customer)
WHERE 
t2.deleted = 0 
AND 
t1.email NOT IN ( SELECT email from table2)

Is this as good as it can get?

Thanks

user389391
  • 97
  • 1
  • 8
  • 1
    This is the common way to write it. I usually prefer a `LEFT JOIN` with `NULL` test. See the linked question for various ways. You can try them to see which is fastest with your data. – Barmar Feb 23 '22 at 23:42

0 Answers0