我想在表格中显示最后修改的元素,但将结果限制为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行编辑的行......
我缺少什么?!
答案 0 :(得分: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
答案 1 :(得分: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
答案 2 :(得分:0)
您只需在DESC
子句中添加ORDER BY
即可按降序对记录进行排序。
ORDER BY LastModified DESC
默认情况下,ORDER BY
子句按ASCENDING
顺序排序。