sotn
sotn

Reputation: 2101

SQL query from minus to join

How can I translate the following query:

select col1,col2,col3 from table1
minus
select col1,col2,col3 from table2

into a query that uses a join clause?

Upvotes: 0

Views: 545

Answers (1)

Mitch Wheat
Mitch Wheat

Reputation: 300728

select t1.col1, t1.col2, t1.col3 
from table1 t1
left join table2 t2 on t1.col1 = t2.col1 and t1.col2 = t2.col2 and t1.col3 = t2.col3
where t2.col1 is null

SQLFiddle

Upvotes: 4

Related Questions