日期:2014-05-16 浏览次数:20995 次
select * from phpa_ssq where find_in_set('100',concat_ws(',',num1,num2,num3,num4,num5,num6) ) and find_in_set('500',concat_ws(',',num1,num2,num3,num4,num5,num6) );
------解决方案--------------------
select * from phpa_ssq a where instr(concat(num1,',',num2,',',num3,',',num4,',',num5,',',num6), '100')>0 and instr(concat(num1,',',num2,',',num3,',',num4,',',num5,',',num6) ,'500')>0;
------解决方案--------------------
mysql> select * from phpa_ssq where find_in_set(100,concat_ws(',',num1,num2,num3,num4,num5,num6) ) and
-> find_in_set(500,concat_ws(',',num1,num2,num3,num4,num5,num6) );
+------+------+------+------+------+------+
| num1 | num2 | num3 | num4 | num5 | num6 |
+------+------+------+------+------+------+
| 100 | 120 | 150 | 170 | 200 | 500 |
+------+------+------+------+------+------+
1 row in set (0.00 sec)
select count(*) from phpa_ssq where (num1='500' or num2='500' or num3='500' or num4='500' or num5='500' or num6='500' ) and (num1='100' or num2='100' or num3='100' or num4='100' or num5='100' or num6='100' )
------解决方案--------------------
select * from phpa_ssq
where (0+num1=500
or 0+num2=500
or 0+num3=500
or 0+num4=500
or 0+num5=500
or 0+num6=500
)
and (
0+num1=100
or 0+num2=100
or 0+num3=100
or 0+num4=100
or 0+num5=100
or 0+num6=100
)