where id in用 order by field 保持排序

mac2022-06-30  23

转载自http://blog.linuxphp.org/archives/1588/

先看下mysql的默认排序

select id from article where id in(63261,63262,63269);

 

+-------+ |   id     | +-------+ | 63261 | | 63262 | | 63269 | +-------+   如果我想63262在第一个63261在最后一个怎么办? select id from article where id in(63261,63262,63269) order by field(id,63262,63269,63261); +-------+ |   id     | +-------+ | 63262 | | 63269 | | 63261 | +-------+

转载于:https://www.cnblogs.com/doubilaile/p/4643319.html

最新回复(0)