Hello.
I'm building a shoutbox in PHP to display the messages in ascending order, like you see in every chat nowadays.
I'm limiting the site so it only shows the latest 20. However, when doing "ORDER BY `id` ASC LIMIT 20" it retrieves the first 20 (or the "oldest 20") in the database.
Considering my brain won't work with me right now, I need some help to achieve this. How's the SQL query for getting the LATEST 20 inputs in the database, while still ordering them in ascending order?
I'm building a shoutbox in PHP to display the messages in ascending order, like you see in every chat nowadays.
I'm limiting the site so it only shows the latest 20. However, when doing "ORDER BY `id` ASC LIMIT 20" it retrieves the first 20 (or the "oldest 20") in the database.
Considering my brain won't work with me right now, I need some help to achieve this. How's the SQL query for getting the LATEST 20 inputs in the database, while still ordering them in ascending order?

Comment