--1 SELECT a.* FROM a LEFT JOIN b ON a.key = b.key WHERE (b.key IS NULL) --2 select *, case when (select count(*) from b where id = a.id)>0 then 1 else 0 end as flag from a --3 select id from (select a.id,b.conid from a left join b on a.id=b.conid) as res where res.conid is null select id from a where id not in (select conid from b) --4 select id,mian=(case when isnull(a.mian,'')='' then b.mian else a.mian end) from a left join b on a.id=b.id