I have a small chat app that I am working on, but got stuck with ordering and limiting the results that are displayed from the DB. I want to limit the results by 20 and display the latest results at the bottom of the HTML container DIV, I would need to get the highest ID of the chat table – 20 and then display those results. This is my current query
SELECT chat_box.*,
(SELECT MAX(chat_id) AS last FROM chat_box) AS last
FROM chat_box
ORDER BY chat_id ASC
LIMIT last,20
You don’t need a
MAXif you just want to display the last 20 entries of the table.Update