SQL standards specifically indicate that tables do not have a โnaturalโ order. Therefore, the database engine can return a query without ORDER BY in any order. An order can change from one request to another, because most engines prefer to return data in any order so that they can receive it most quickly.
Therefore, if you want the data to be in a specific order, you must include the column in your table whose job is a proxy for the order in which you added records to the table. Two common ways to do this is to use the auto-increment field, which will be in numerical order from the oldest to the latest record, and the TIMESTAMP column, which does just what it says. When you have such a column, you can use ORDER BY ColumnName in your search to get an ordered set of results.
source share