如何让SQL语句不执行默认排序,而是按照in语句的顺序返回结果

Oracle:

select name from order where order_id in'111','222','333','444','555','666')order by instr('111,222,333,444,555,666',order_id);

Mysql:

第一种:select name from order where order_id in ('111','222','333','444','555','666') order by instr(',111,222,333,444,555,666,',CONCAT(',',order_id,','));

第二种:SELECT * FROM `shop` WHERE deleteFlag=0  and (shopId in (4002,4097,4093)) ORDER BY FIELD( shopId, 4002, 4097, 4093)

摘自:https://blog.csdn.net/u011884440/article/details/70510805

posted @ 2018-10-20 00:19  温柔的风  阅读(422)  评论(0编辑  收藏  举报