我想在表格中显示最后修改的元素,但将结果限制为 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 已编辑的行...
我错过了什么?!
我想在表格中显示最后修改的元素,但将结果限制为 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 已编辑的行...
我错过了什么?!
默认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
试试这个
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
您只需要添加子句即可按降序DESC
对ORDER BY
记录进行排序。
ORDER BY LastModified DESC
默认情况下,ORDER BY
子句按ASCENDING
顺序排序。