表a 
字段aa,bb,cc,都是字符型
表b
字段
   dd,bb 我现在要返回a中的记录,要求返回aa,cc,数字1或0
 
1表示a中的bb在表b中,0表示a中的bb不存在表b中
用什么来写,这个条件判断怎么写,bb是字符窜型噢~~

解决方案 »

  1.   

    select aa,cc,case when exists(select 1 from 表b where bb=t.bb) then 1 else o end from 表a t
      

  2.   

    Select 
    aa,
    (Case When Exists(Select bb From b Where bb=A.bb) Then 1 Else 0 End)  As 是否存在,
    cc
    From A
      

  3.   

    打了幾個中文字就慢了。PS:紅塵的ID改了,怎麼答貼的風格也改了。 :)
      

  4.   

    select 
        t.aa,
        t.cc,
        case when exists(select 1 from 表b where bb=t.bb) then 1 else 0 end
    from 
        表a t
      

  5.   

    电脑使用起来太费劲,连UtralEdit都不允许装,只能用写字板。