急求SQL语句!20分钟内给答案的!200分

来源:百度知道 编辑:UC知道 时间:2024/06/11 02:12:06
2张表结构一样,A表数据包含B表数据,主键是联合主键!
怎么样从A表里选出不在B表的数据!
有点绕,脑子有点混了!给出关键思路的都可以!
大佬,联合主键啊!

select * from [A] where ID not in (select ID from [B])

select * from [A] where ID not in (select ID from [B] where ID is not null) and ID is not null
其中ID为主键,A表和B表都有并相同

暂时想到个笨办法就是在存储过程中循环比对:(