日期:2014-05-16 浏览次数:20739 次
C_file ID spile 1 2,10,11 2 2,3,20,22 3 1,6,8 4 5,6,1,9
SQL: select * from C_file where spile LIKE '%1%'
select * from C_file where find_in_set(1,spile)
------解决方案--------------------
mysql> select * from test; +----+-----------+ | id | name | +----+-----------+ | 1 | a,1,2 | | 2 | 2,3,20,30 | | 3 | 1,6,8 | | 4 | 5,6,1,9 | | 5 | e | +----+-----------+ 5 rows in set (0.00 sec) mysql> select *from test where instr(concat(',',name,','),',1,')<>0; +----+---------+ | id | name | +----+---------+ | 1 | a,1,2 | | 3 | 1,6,8 | | 4 | 5,6,1,9 | +----+---------+ 3 rows in set (0.00 sec) mysql>