时间:2021-07-01 10:21:17 帮助过:9人阅读
加上order by 字段1,字段2,字段3
{
select * from 表名 order by 猪,狗,牛;
}应该就可以了
猪,狗,牛是在同一字段中的,楼上的不行。
可以这样写,例如字段名叫shengxiao
$sqlstr = "select *,IF(shengxiao='猪啊',1, IF(shengxiao='狗啊',2,3)) as s from table order by s";
加上order by 字段1,字段2,字段3
{
select * from 表名 order by 猪,狗,牛;
}应该就可以了
$str="select id from biaoqian where (biaoti like '%猪%' or b.biaoti like '%狗%' or b.biaoti like '%牛%' or b.biaoti like '%猪狗牛%' ) order by id desc limit 10";
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 猪啊 猪 狗啊 狗 牛啊 牛
order by xx like '%猪%', xx like '%狗%', xx like '%牛%' desc
搞定了,非常感谢