Reputation: 4522
I would like to show the last modified elements in a table, but limit the results to 5, so I did:
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
The problem with this query is that it is returning the first 5 rows of the table, not the last 5 edited rows...
What am I missing?!
Upvotes: 1
Views: 135
Reputation: 263693
You just need to add DESC
in the ORDER BY
clause to sort the record in descending order.
ORDER BY LastModified DESC
by default, the ORDER BY
clause is sorted by ASCENDING
order.
Upvotes: 0
Reputation: 877
Try this
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
Upvotes: 0
Reputation: 14333
Default ORDER BY
is Ascending order. You want descending
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
Upvotes: 1