1.生成测试数据: create table team(name varchar(32),person varchar(32)); insert into team values('A','Tom'); insert into team values('A','Jim'); insert into team values('A','Anny'); insert into team values('B','Ivy'); insert into team values('B','Henry');& ...
select * from 表A where id not in (select id from 表B) 但是not in 效率不高,建议用: select a.* from A left join B on a.id=b.id where isnull(b.id) http://blog.163.com/yunzhongshu_1/blog/static/332365752011051411620/ ...