Guys, how to display the last 10 messages from the top down?

SELECT * FROM Messages ORDER BY id DESC LIMIT 5 

Displays the last 10 messages, but I need to top down that would display.

  • But how does it lead them if not from the top down? the location of the results on the screen does not depend on the sql query ... - Mike
  • I need the last posts to be at the bottom, and not at the top of the last 10 - Members
  • one
    @Members, so who bothers you with a javascript loop (since it is listed in your tags) in the reverse order? - Visman

1 answer 1

In my opinion, to flip user output in a sql query, this is a pretty weary way of handling data, but nonetheless:

 SELECT * FROM ( SELECT * FROM Messages ORDER BY id DESC LIMIT 5 ) AS t1 ORDER BY id; 

IMHO, it is more logical to prepare data for output to the user on the client side. For this is the function Array.prototype.reverse .