列A字段中含有1或2或3,列B字段是:甲、乙、丙,
如何进行对照,1对应甲,2对应乙,3对应丙,找出没有对应上的数据。A         B
阿1#     甲
去2限    乙
过2      丙
得到最后一行。

解决方案 »

  1.   

    select *
    from tab
    where not (a like '%1%' and b='甲' or a like '%2%' and b='乙' or a like '%3%' and b='丙')
    给的数据怎么这么晕
      

  2.   

    select * from tb
    except
    select * from tb
    where (a=1 and b='甲' ) 
        or (a=2 and b=b='乙' )
        or (a =3  and b='丙')
      

  3.   

    select * from tb where not B=case when charindex('1',A,1)>0 then '甲'
                                  when charindex('2',A,1)>0 then '乙'
                                  when charindex('3',A,1)>0 then '丙' end