日期:2014-05-17 浏览次数:20520 次
create table a(fid varchar(10), fname varchar(10)) insert into a values('001', '公式A') insert into a values('002', '公式B') create table b(divcode varchar(10),fname varchar(10),fid varchar(10), aflag int) insert into b values('0001' , '单位A' , '001' , 1) insert into b values('0001' , '单位A' , '002' , 1) insert into b values('0002' , '单位B' , '001' , 1) insert into b values('0002' , '单位B' , '002' , 0) insert into b values('0003' , '单位C' , '002' , 1) go select fname from b where aflag = 1 group by fname having count(1) = (select count(1) from a) drop table a , b /* fname ---------- 单位A (所影响的行数为 1 行) */
------解决方案--------------------