【发布时间】:2017-07-08 18:24:12
【问题描述】:
我想显示七个最近的条目,但我希望使用 PHP/MySQL 以升序对条目进行排序。这是我当前的代码:
$sql="SELECT date, weight, COUNT(*) AS 'count' FROM weights GROUP BY date ORDER BY date ASC";
注意:我已尝试添加“LIMIT 7”,但这只会显示条目 1-7(而不是 15-21,这正是我想要的)。
另请注意:我曾尝试在 Stack Overflow 和 Google 上进行搜索,但代码不起作用。
【问题讨论】:
-
LIMIT 15, 7会告诉你 15 - 21 -
您可以在此处阅读更多信息 dev.mysql.com/doc/refman/5.7/en/select.html。
With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. -
我要的是最近的七个条目,而不是像 15-21 这样的特定范围。