时间:2021-07-01 10:21:17 帮助过:20人阅读
select * from (select * from 表 where status = 1 order by time)aunion allselect * from (select * from 表 where status = o order by time desc)b
select * from table order by status desc,if(status=1,'time asc','time desc');
order by time (case when status = 1 then desc else asc end)
select * from (select * from 表 where status = 1 order by time)aunion allselect * from (select * from 表 where status = o order by time desc)b
select * from table order by status desc,if(status=1,'time asc','time desc');
去试了没?
你用的什么数据库?
select * from table order by status desc,if(status=1,'time asc','time desc');
select * from tbl_name order by status=1 desc, time*if(status=1,1,-1)
order by time (case when status = 1 then desc else asc end)
select * from tbl_name order by status=1 desc, time*if(status=1,1,-1)
order by time (case when status = 1 then desc else asc end)
select * from tbl_name order by status=1 desc, time*if(status=1,1,-1)
order by time (case when status = 1 then desc else asc end)
select * from (select * from 表 where status = 1 order by time)aunion allselect * from (select * from 表 where status = o order by time desc)b
SELECT * FROM (SELECT * FROM `table2` WHERE `status`=1 ORDER BY time ASC) aUNION ALLSELECT * FROM (SELECT * FROM `table2` WHERE `status`=0 ORDER BY time DESC) b
select * from (select * from 表 where status = 1 order by time)aunion allselect * from (select * from 表 where status = o order by time desc)b
SELECT * FROM (SELECT * FROM `table2` WHERE `status`=1 ORDER BY time ASC) aUNION ALLSELECT * FROM (SELECT * FROM `table2` WHERE `status`=0 ORDER BY time DESC) b