我想判断:值'AA'是否在数据表T的字段stu中,如果在表T中并且T中的另一字段
cla是否等于'BB',该怎么写啊谢谢~~~

解决方案 »

  1.   

    select * from tb
    where charindex('AA',stu)>0 and cla='BB'
      

  2.   

    ?
    select * from t where stu='AA' and cla='BB'
      

  3.   

    if exists(select 1 from T where stu='AA')
    begin
        if exists(select 1 from T where stu='AA' and cla='BB')
            print 'AA存在且cla=BB'
        else
            print 'AA存在但cla<>BB'
    end
    else
        print 'AA不存在'
      

  4.   

    判断:值'AA'是否在数据表T的字段stu中,如果在表T中并且T中的另一字段
    cla是否等于'BB',该怎么写啊谢谢~~~
    -----------------------
    select * from t where stu='aa' and cla='bb'
      

  5.   

    select '是否符合条件'=case when charindex('AA',stu)>0 and cla='BB' then '符合' else '不符合' end
    from T
      

  6.   


    select 'isAA'=(case stu when like '%'+'AA '+'%' then 1 else 0 end)
    from T
    select  fanhui = isnull( select cla where 'isAA' =1 and cla='BB')