I make a chat like in VK. You need to display the latest entries (Messages) as ASC. Suppose in the record base from 1 to 30, I need to display the records within 20-30, that is, through DESC LIMIT 10. But how can I make them as ASC after the output? Not 30, 29, 28 ... 20 and 20,21,22 ... 30?

  • I think something like a cycle at the conclusion? Shove an array and assign ids in reverse order? - Albert Ushakov

1 answer 1

We make a selection of the last 10, then in the external query we re-sort in a different order:

select * from ( select * from table order by id desc limit 10 ) A order by id 
  • Hmm, they quickly solved the problem) Bravo) - Albert Ushakov