我有这张桌子:
ID | product | image | sort
---------------------------
1 | 1 | img1 | 1
2 | 1 | img2 | 1
3 | 1 | img3 | 2
4 | 2 | img4 | 1
5 | 2 | img5 | 2
如何按产品选择排序最低,ID最低的记录?
我想得到的结果如下:
ID | product | image | sort
---------------------------
1 | 1 | img1 | 1
4 | 2 | img4 | 1
答案 0 :(得分:3)
试试这个:
Select * from table WHERE = (Select MIN(sort) from table) ORDER BY ID ASC group by product