SQL自定义排序
-- 自定义排序
select
FIND_IN_SET(str, 'a,b,c,d,e') as str_fis
,str
from (
select 'b' as str union all
select 'a' as str union all
select 'd' as str union all
select 'c' as str union all
select 'f' as str union all
select 'g' as str union all
select 'e' as str
) t1
order by str_fis
;

注意点
只支持可以穷举出来的,如不在范围内,则为0,会排在最前,不支持排在最后。

浙公网安备 33010602011771号