select *,case when exists (select 1 from 表2 where ww=表1.aa) then '已登记' else '未登记' end as DD
from 表1 

解决方案 »

  1.   

    or:select a.*,case when b.ww is null then '未登记' else '已登记' end as DD
    from 表1 a left join (
    select diatinct ww from 表2
    ) as b
    on a.aa=b.ww
      

  2.   

    oracle下的写法:select aa,bb,cc,
    nvl( ( select '已登记' from t2 b where a.aa = b.ww)   ,'未登记') as dd
    from t1 a
      

  3.   

    select 表1.AA,表1.BB,表1.CC,case when 表2.TT is null then '未登记' else '登记' end as DD
    from 表1 left join 
    表2 ON 表1.AA=表2.AA
      

  4.   

    select 表1.* ,
    case when ww is not null then '已登记' else '未登记' end DD
    from 表1
    left join 表2
    on 表1.AA = 表2.WW
      

  5.   

    UP jmcy12(小兔子)
    比较好读