mysql数据库怎么根据多个字段同时排序?

2024-11-13 04:04:48
推荐回答(2个)
回答1:

您好,您这样:
order by last_time,id desc 这种方式last_time默认是升序的
order by last_time and id desc 这种方式两个字段都是降序的
应该先分组,
select id,last_time from yourtablename group by last_time order by last_time desc,id desc

回答2:

sql 使用order by 排序

select * from table order by value1,value2
根据字段value1和value2排序默认是升序
select * from table order by value1,value2 desc
按照降序排序