2012-11-28 113 views
1

我有在包含这样检查任何列包含字符从一个字符串

class1 class2 class3 class4 
A  D  0  0 
0  A  B  0 
B  0  0  C 
A  0  D  0 

值的表列,我有一个字符串像First="A,B"Second="C,D"

如何检查任何一个从字符串包含在这些四列的性格

回答

0
select * from yourtable where class1 in('A,B,C,D') 
UNION 
select * from yourtable where class2 in('A,B,C,D') 
UNION 
select * from yourtable where class3 in('A,B,C,D') 
UNION 
select * from yourtable where class4 in('A,B,C,D') 
+0

感谢您ÿ我们的回复,但需要时间 – Sajir

+0

尝试此更新后的查询 – AnandPhadke

0
select * from t 
where 

'A,B' like '%'+class1+'%' 
or 
'A,B' like '%'+class2+'%' 
or 
'A,B' like '%'+class3+'%' 
or 
'A,B' like '%'+class4+'%' 
相关问题