At 12:07 PM +0430 9/20/09, Parham Doustdar wrote:
I'm guessing that when a row in a MySQL table is removed, the ID
colomns of the rows which come after that row are not changed. For
Now, if I want to remove the third rows, the ID colomn would be
I was wondering if there was a way to fix it through a query, so I
wouldn't have to use a for statement in PHP to fix it?
This is a common problem with people who are new to databases. The
sequence of the index of tables has nothing to do with anything
important -- there is no reason to be fearful of, or concerned with,
gaps. Gaps are normal and a customary part of the database operation.
I often hear managers/clients say "How do we correct that gap?" --
the simple answer is "We don't" and there is no reason to look upon a
gap in a sequence as if it needs correcting.
Now, if you want to display a sequence of records (like a product
listing), there is no problem with you reading all the products in
your database, sorting them, and listing them in numerical order --
however, that listing has nothing to do with the index of the table.
Similarly, you may even want to list your products in alphabetical
order and you can do that too, but again that listing has nothing to
do with the index of the table.
So in the end, the index in a table has nothing to do with how you
store or list your data -- it simply is an internal thing that the
database needs to keep track of unique records.
My advice, allow the database to use the index as it needs and you
use the data as you need.
http://sperling.com http://ancientstones.com http://earthstones.com
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php