Reputation: 1044
I would like to select data from a table which looks like ID|FOO|CITY|BAR
there is another table where all data which has been selected yet will be stored so that I get unique results. This table looks like ID|ID_from_other_table
Now I'm stucking if I either should use a left join or a union? Which one is faster and, how can I set this up the correct way?
Upvotes: 0
Views: 90
Reputation: 44581
left join
would be probably faster in MySQL rather than other anti-join patterns like not in
and not exists
.
select t1.*
from table1 t1
left join table2 t2 on t1.id = t2.id_from_other_table
where t2.id is null
Upvotes: 1