Ok, I got the great website I'm making as a hobby kinda as I'm learning PHP and MySQL. Great combination, and I love them both.
Now I've been learning MySQL and have been creating stuff relying on that.
So, I store information in a table and have an auto_increment ing table (column name = id)
I've been messing around and adding and deleting rows with a php interface. But I want to know how to change my table so that I don't have gaps in it.
For example, my first row id=1 second id=3, then third id=20, fourth = 22. How do I make it so that I don't have gaps and the table reindexes or something everytime I delete a row.
I want row 1 id=1, row 2 id=2, row 3 id=3, etc.
But I need t obe able to delete things sometimes and I want the id numbers to fix themselves so they only count rows that are created.
Any suggestions?
I'm just looking for a mysql query or something that I can use to fix the table's id's :)
Question
exien
Ok, I got the great website I'm making as a hobby kinda as I'm learning PHP and MySQL. Great combination, and I love them both.
Now I've been learning MySQL and have been creating stuff relying on that.
So, I store information in a table and have an auto_increment ing table (column name = id)
I've been messing around and adding and deleting rows with a php interface. But I want to know how to change my table so that I don't have gaps in it.
For example, my first row id=1 second id=3, then third id=20, fourth = 22. How do I make it so that I don't have gaps and the table reindexes or something everytime I delete a row.
I want row 1 id=1, row 2 id=2, row 3 id=3, etc.
But I need t obe able to delete things sometimes and I want the id numbers to fix themselves so they only count rows that are created.
Any suggestions?
I'm just looking for a mysql query or something that I can use to fix the table's id's :)
Thx for your help!
exien
Link to comment
Share on other sites
3 answers to this question
Recommended Posts