select * from tb where charindex('AA',stu)>0 and cla='BB'
? select * from t where stu='AA' and cla='BB'
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不存在'
判断:值'AA'是否在数据表T的字段stu中,如果在表T中并且T中的另一字段 cla是否等于'BB',该怎么写啊谢谢~~~ ----------------------- select * from t where stu='aa' and cla='bb'
select '是否符合条件'=case when charindex('AA',stu)>0 and cla='BB' then '符合' else '不符合' end from T
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')
where charindex('AA',stu)>0 and cla='BB'
select * from t where stu='AA' and cla='BB'
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不存在'
cla是否等于'BB',该怎么写啊谢谢~~~
-----------------------
select * from t where stu='aa' and cla='bb'
from T
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')