create table t001( id int , name varchar(20), city varchar(32), class varchar(32)) ;
insert into t001 values(1,‘tom’,‘beijing’,‘yiban’) ;
insert into t001 values(2,‘jack’,‘beijing’,‘yiban’) ;
insert into t001 values(3,‘lili’,‘shanghai’,‘erban’) ;
insert into t001 values(4,‘david’,‘nanjing’,‘yiban’) ;
insert into t001 values(5,‘peter’,‘hangzhou’,‘erban’) ;
> select *
> from t001
> order by case when class='yiban' then 1
> when class='erban' then 2 end
> desc
> ;
> select *
> from t001
> order by
> field(name,'lili','tom','peter')
> ;
> select *
> from t001
> order by locate(city ,'nanjing,beijing,')
> ;`
> select *
> from t001
> order by instr('hangzhou,nanjing,beijing',city)
> ;`
—本文待更新