我很难理解应该如何写, 我有一个由固定数字列和递增数字列组成的键。
我想让选择查询仅返回每个固定数字的最新行。
例如:
20, 1
20, 2
20, 3 <-- Should only return these rows
25, 1
25, 2 <--
30, 1
30, 2
30, 3 <--
是否可以在单个查询中编写此内容,而不必在 php 中迭代结果?
最佳答案
试试这个::
select max(column1), column2
from table
group by column2
关于php - SQL 查询问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19033478/