ps122

导航

 

 

--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

 

posted on 2017-01-08 18:23  ps122  阅读(1928)  评论(0编辑  收藏  举报