a strange problem faced me with my database
when i insert a data into a table suppose a, b, c, d
i expect that they are inserted in rows like this
id value
1 a
2 b
3 c
4 d
but what happens something else like this
id value
4 d
3 c
2 b
1 a
and sometimes like this
id value
1 a
3 c
2 b
4 d
but when i converted the table from MyIsam to InnoDB i think this problem has finished . What happens ?!
Mysql Problem with id
Moderator: General Moderators
Never be dependent on the physical order of rows in a database. If you do an insert, then a select, there is no guarantee that the last row you inserted will be the last row returned by the select.
Make sure you use ORDER BY when retrieving records, or add in your own order field or inserted datetime field. Even if the problem seems to have gone away, don't depend on those records being ordered by when they were inserted.
Make sure you use ORDER BY when retrieving records, or add in your own order field or inserted datetime field. Even if the problem seems to have gone away, don't depend on those records being ordered by when they were inserted.