数据:
id bb
1 14,35
2 5,11,12,125,36
3 3,23,45,15,1
4 651
5 5,1,6
6 1,7
例如,我不想获取值为“1”的 id。因此 id(3,5,6) 应该返回 ,而不是其他带有“14”或“11”的返回。
数据库:Mysql
最佳答案
这不是最有效的解决方案,但它可能会给你带来你想要的东西:
select id from MyTable where bb like '%,1,%' union
select id from MyTable where bb like '1,%' union
select id from MyTable where bb like '%,1' union
select id from MyTable where bb like '1'
干杯
关于sql - 如何从包含组合数据的列中获取结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1061557/