select * from product where id in (3,4,8,5,1,6,2,7) 并不会按查询的id顺序返回数据,添加order by field就可以解决,如select * from product where id in (3,4,8,5,1,6,2,7) order by field(id,3,4,8,5,1,6,2,7);
select * from product where id in (3,4,8,5,1,6,2,7) 并不会按查询的id顺序返回数据,添加order by field就可以解决,如select * from product where id in (3,4,8,5,1,6,2,7) order by
order by
field(id,3,4,8,5,1,6,2,7);
mysql使用in的时候返回数据顺序不一样
原文:https://www.cnblogs.com/5jia0/p/15001896.html