当前位置: 代码迷 >> Sql Server >> 求一条经典SQL语句,该如何解决
  详细解决方案

求一条经典SQL语句,该如何解决

热度:135   发布时间:2016-04-27 19:17:22.0
求一条经典SQL语句
表A(Code NVARCHAR(50),Name NVARCHAR(50))
数据为
A B
B C
C D
表B(Code NVARCHAR(50),Name NVARCHAR(50))
数据为
A B
B C
如何从A表中查询不在B表中的数据
既查出 A表中的行 C D 


------解决方案--------------------
SQL code
select * from 表Aexceptselect * from 表B
------解决方案--------------------
另一種寫法,
SQL code
select a.*from 表A aleft join 表B bon a.Code=b.Code and a.name=b.namewhere b.Code is null and b.name is null
  相关解决方案