时间:2021-07-01 10:21:17 帮助过:57人阅读
$sqlstr = "select *,IF(shengxiao='猪啊',1, IF(shengxiao='狗啊',2,3)) as s from table order by s";
create temporary table T
select '猪啊' as f
union select '牛啊'
union select '狗啊';
select *, if(locate('猪', f), '猪',if(locate('牛',f),'牛', if(locate('狗',f),'狗',''))) as x
from T order by find_in_set(x, '猪,狗,牛')
f x
猪啊 猪
狗啊 狗
牛啊 牛