Reputation: 29
how can I rewrite the following query using JOIN
SELECT *
FROM table1
WHERE id NOT IN
(
SELECT t1Id
FROM table2
);
Upvotes: 2
Views: 343
Reputation: 171579
SELECT *
FROM table1 t1
left outer join table2 t2 on t1.id=t2.id
where t2.id is null
Upvotes: 8
Reputation: 25390
SELECT * FROM table1 t1
WHERE NOT EXISTS(
SELECT *
FROM table2 t2
Where t1.Id = t2.t1Id);
Upvotes: 0