现在有这么个需求:
数据库有个表: distribution, 表中有个productIdStr字段, 存储的是id字符串.
例如: 1,2,3,4,5,6,7,88
现在要查询包含id为4的数据:
SQL如下:
select * from distribution d where (d.productIdStr like '4,%') or (d.productIdStr like '%,4,%') or (d.productIdStr like '%,4');
现在有这么个需求:
数据库有个表: distribution, 表中有个productIdStr字段, 存储的是id字符串.
例如: 1,2,3,4,5,6,7,88
现在要查询包含id为4的数据:
SQL如下:
select * from distribution d where (d.productIdStr like '4,%') or (d.productIdStr like '%,4,%') or (d.productIdStr like '%,4');