A similar question has already been asked by another user, but the answer to it did not suit me. I need to output data from the table (sorting by date, ie, the newer the message, the higher it is). It is logical to assume that we need sorting in descending order. ORDER BY my_date ASC. But after all, when we add to the database, they are added to the bottom of the table, so in order to sort by date, it’s enough just to start reading the lines from the bottom. How in mysql to make so that to start to select a line from below, but not from above? (Is it possible to write down LIMIT COUNT(*)-1 )?

  • one
    > sorting by date, i.e. the newer the message, the higher it is. Then, on the contrary, you need to do ORDER BY my_date DESC - KiTE
  • No sorting is impossible at all! - gympi
  • 3
    and you ask the wrong question, so do not get the correct answer. what the wording "I need sorting descending" is not a question. How to choose the line below and not the top? and why you decide that they are stored in the database, they are displayed for you. - jmu
  • @jmu agree - gympi

2 answers 2

You can try to create an index on my_date descending. But without the ORDER BY guarantee that the records will be retrieved in accordance with this index, no.

  • Without sorting, there is no guarantee of it at all) - gympi

In any book on SQL and all database vendors write in capital letters for programmers that "no one guarantees a strict sequence of records in the table," it is important to know, and then id will start looking at the last entry.

  • I will add: this fact is due to the fact that when writing to a table, subd writes to a free memory area, but this one may be between two previous records, in the event that which record was deleted. - gympi
  • Well, duck and prima key exhibited? - or_die
  • Explain about primarikay 4, 8 and 16 byte cell, which have no idea about this, not the level of abstraction, when reading from the database of rows without sorting, you get the answer as it lies in the file system - gympi