I am doing easy web based chat so I need to get (for example) 30 latest messages from a MySQL database. That doesn’t make any problem but how can I take the data in up side down order? I mean, the oldest message is the first. I have to take latest 30 records by added time.
EDIT: Thanks for the answers, but…
ORDER BY added DESC LIMIT 30
gives:
15, 14, 13, 12, 11
…and I need:
11, 12, 13, 14, 15
I know I can get it using a subquery. Is there any better method?
As mentioned above, a simple “desc” sort gets the oldest 30 messages, not the newest (though they are in the right order).
Actually all you need is:
I hope this helps.