create table lzh_test(
id varchar(20),
name varchar(20),
sort varchar(20)
);
insert into lzh_test values(1,'张三',1);
insert into lzh_test values(2,'王五',3);
insert into lzh_test values(3,'赵六',4);
insert into lzh_test values(4,'李四',2);
insert into lzh_test values(2,'王五',3);
select * from lzh_test;
-- 不排序
select * from (select uo.* from lzh_test uo order by sort desc) tt;
-- 排序(limit的值需要大于总行数)
select * from (select * from lzh_test order by sort desc limit 100000000) tt;
-- 排序
select * from (select uo.* from lzh_test uo,(select @num:=0) t order by sort desc) tt;
-- 排序(不能有完全重复的行)
select * from (select distinct uo.* from lzh_test uo order by sort desc) tt;