从减号到连接的SQL查询

时间:2013-03-10 01:48:29

标签: sql join

如何翻译以下查询:

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

进入使用join子句的查询?

1 个答案:

答案 0 :(得分:4)

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