首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-01-11 
求一条经典SQL语句表A(Code NVARCHAR(50),Name NVARCHAR(50))数据为A BB CC D表B(Code NVARCHAR(50),Name

求一条经典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 

热点排行