5 个回答
select * from table where substring_index(field, ',', 1) = '10'
截取第一个逗号前面的部分

不太明白你的问题,按照我的理解不就是简单的select * from test where id = 10。

使用模糊匹配:select * from test where column like "%10%"
PS:感觉这样的需求有些奇怪,是否数据库设计不合理。

从题意上看,解决办法可以是
自定义函数,切分字段用的,然后再判断,
1.自定义函数,待补
2.查询语句
select * from table where 1=hasTen(column)

粗暴妥协一点的做法
select * from table where column like '10,%'
||
select * from table where column like '%,10,%'
||
select * from table where column like '%,10'

如果能够保证字段一定是a,b的形式或许会好解决一点

参考一下:select * from test where concat(',', column, ',') like "%,10,%"

推荐问题