请教一MYSQL查询语句

来源:百度知道 编辑:UC知道 时间:2024/05/14 05:01:53
我post一个id为1,要查询所有target_ids字段中包含1的条目,不要模糊查询。

如:target_ids字段1为1,2,3。字段2为1,4

怎么查呢?
楼下方法好像target_ids中包含12,13时会不准确

3楼的方法是不是如果我每个页面显示30条数据,其中有5条不符合,就只输出了25条了?

select target_ids from table where inStr(target_ids,1)>0

select * from table where target_ids like %1%

1.你先select * from table where target_ids like %1%;查
2.循环
3.对target_ids值拆分数组
4.循环对每个数组的值判断
5.如果等于您设定的值就输出 条目