Wednesday, August 18, 2010

Why does mysql keep inserting data in random places and how can I fix this?

I am using mysql 5.0.51a with php 5.2.5





I am using the insert command to enter data.





It keeps inserting data in random locations in the table, which is messing up my web app.





It did use an id column at one time.





I've tried flushing the table, and remaking the table with phpmyadmin's sql dump.





How can I fix this? I just want mysql to insert data at the end of the table, like it should.Why does mysql keep inserting data in random places and how can I fix this?
Data is inserted pseudorandomly in a database. The order in which you see it in a select statement is determined by the ORDER BY or GROUP BY parts of the select. *NO* database guarantees insert order. (It's not actually random, but you'd have to study the source code of the database to learn how the order is determined. It's almost never last-in/last-in-order.)





If you're depending on the latest inserted data being last in an unordered select, that's where the problem lies.

No comments:

Post a Comment