Mysql 在 InnerDB 引擎下,查询不带 ORDER BY,会根据主键来排序,从小到大;
带 ORDER BY 的升序,降序:
ORDER BY `id` ASC -- 升序
ORDER BY `id` DESC -- 降序
查询结果按照指定的 id 列进行排序:
ORDER BY FIELD(`id`, 5, 3, 7, 1)
例如:
SELECT * FROM user WHERE id IN (5,3,6,1) ORDER BY FIELD(id,5,3,6,1);