替代Oracle的minus写法

1 SELECT *
2 FROM Table1 a
3 LEFT JOIN Table2 b
4   ON a.Col1 = b.Col1 AND a.Col2 = b.Col2
5 WHERE b.Col1 IS NULL

适用非Oracle的数据库,还有一种写法总感觉没这优雅,因为用了 NOT EXISTS

1 SELECT *
2 FROM Table1
3 WHERE NOT EXISTS (
4 SELECT *
5 FROM Table2
6 WHERE Col1 = Table1.Col1
7 AND Col2 = Table1.Col2
8 )
posted @ 2012-11-22 14:14  易木  阅读(464)  评论(0编辑  收藏  举报