select a.* from tbl1 a
left join tbl2 b
on a.key = b.key
where b.key is null
select A.* from TABL1 A
where not EXISTS(select 1 from TABL2 WHERE TABL2.[KEY]=TABL1.[KEY])
select a.* from tbl1 a
left join tbl2 b
on a.key = b.key
where b.key is null
还有一个问题
a.key = b.key 还是 b.key = a.key他们的区别是什么?
------------------------------------------------------------------------
没有区别,一样的,看着规范些.具体以哪个表为主进行的连接是由left/right join来指定的.
select A.* from TABL1 A
where not EXISTS(select 1 from TABL2 WHERE TABL2.[KEY]=TABL1.[KEY])
select A.* from tbl1 A,tbl2 where A.key > key or A.key < key
select a.* from tbl1 a
left join tbl2 b
on a.key = b.key
where b.key is null
会比
select A.* from TABL1 A
where not EXISTS(select 1 from TABL2 WHERE TABL2.[KEY]=TABL1.[KEY])
本文探讨了SQL中左连接(left join)及不存在子查询(not exists)的应用场景与实现方式,通过具体示例对比了两种方法的区别,并讨论了a.key=b.key与b.key=a.key在SQL连接语句中的等价性。
5825

被折叠的 条评论
为什么被折叠?



