如何按降序对id和sub_id进行排序? [英] How can I sort id and sub_id in descending order?
本文介绍了如何按降序对id和sub_id进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的桌子就像...
id Sub_id name path date
1 33 Sanjay Something here to all Some thing
2 33 Sanjay
3 34 Fariya
4 35 Neeraj
5 35 Neeraj
6 32 Mukesh
7 37 Ravi
8 32 Mukesh
9 32 Mukesh
10 32 Mukesh
当我使用此查询时-表名是Gallery ...
When I use this query - where table name is gallery...
$sql="select * from (select * from gallery order by id desc 4) gallery group by Sub_id desc limit 4";
我需要这种格式
id Sub_id name path date
10 32 Mukesh Something here to all Some thing
7 37 Ravi
5 35 Neeraj
3 34 Fariya
请帮帮我...
推荐答案
尝试一下:
SELECT
MAX(id),
Sub_id,
name,
path,
date
FROM
gallery
GROUP BY
Sub_id
ORDER BY
id DESC
LIMIT 4;
这篇关于如何按降序对id和sub_id进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文