find_in_set()
问:
mysql中怎么按in语句中的id顺序取数据
select * from ecs_goods where goods_id in (14,1,33,23)
按14,1,33,23这个顺序取
答:
在程序中,$idList='14,1,33,23';
select * from ecs_goods where goods_id in ($idList) order by FIND_IN_SET(goods_id,'$idList')
问:
mysql中怎么按in语句中的id顺序取数据
select * from ecs_goods where goods_id in (14,1,33,23)
按14,1,33,23这个顺序取
答:
在程序中,$idList='14,1,33,23';
select * from ecs_goods where goods_id in ($idList) order by FIND_IN_SET(goods_id,'$idList')
本文介绍了如何在MySQL中使用FIND_IN_SET函数按照特定ID顺序查询数据,通过将ID列表作为参数传递,实现数据的有序获取。
862

被折叠的 条评论
为什么被折叠?



