1

我想在表格中显示最后修改的元素,但将结果限制为 5,所以我这样做了:

SELECT
  Id as Id,Title,LastModified
From
  articles
WHERE
  (Author=70 OR Editor=32 OR Publisher=33) && Disab ="0"

Order By   LastModified

LIMIT 0, 5

此查询的问题在于它返回表的前 5 行,而不是最后 5 已编辑的行...

我错过了什么?!

4

3 回答 3

1

默认ORDER BY为升序。你想下降

SELECT
  Id as Id,Title,LastModified
From
  articles
WHERE
  (Author=70 OR Editor=32 OR Publisher=33) && Disab ="0"

Order By   LastModified DESC

LIMIT 0, 5
于 2013-02-23T17:19:20.280 回答
0

试试这个

SELECT
  Id as Id,Title,LastModified
From
  articles
WHERE
  (Author=70 OR Editor=32 OR Publisher=33) && Disab ="0"

Order By   LastModified DESC

LIMIT 0, 5
于 2013-02-23T17:19:20.733 回答
0

您只需要添加子句即可按降序DESCORDER BY记录进行排序。

ORDER BY LastModified DESC

默认情况下,ORDER BY子句按ASCENDING顺序排序。

于 2013-02-23T17:19:24.727 回答