mysql in 排序
select * from table where id IN (3,6,9,1,2,5,8,7);
查出来的数据默认是按照 id asc 排序
如果要使其按照括号里传入值的顺序排序, 可以这样
select * from table where id IN (3,6,9,1,2,5,8,7) order by field(id,3,6,9,1,2,5,8,7);
出来的顺序就是指定的顺序了
mysql in 排序
select * from table where id IN (3,6,9,1,2,5,8,7);
查出来的数据默认是按照 id asc 排序
如果要使其按照括号里传入值的顺序排序, 可以这样
select * from table where id IN (3,6,9,1,2,5,8,7) order by field(id,3,6,9,1,2,5,8,7);
出来的顺序就是指定的顺序了
本文标题:2020-05-13
本文链接:https://www.haomeiwen.com/subject/plwonhtx.html
网友评论