July 11th, 2000, 05:39 AM
I am new to sql so you will have to forgive my questions. I have used MS ACCESS quite allot. When I create 3 records and delete 1 record then add another one the numbering goes out of place.
I create 3 records with the id 1,2,3 I delete record 3, then in the future add another record, it then goes 1,2,4.
Is there anyway in MYSQL to make the numbering go in sequence, if I delete records?.
Thank you for your time.
July 11th, 2000, 05:47 AM
I assume you are talking about auto_increment? If so, what you describe shouldn't happen. If you delete the record with the highest value then the next record inserted should have that value. However, if you delete other than the highest value it won't be replaced. You could reorder with:
delete from table_name where id=$id;
update table_name set id=id-1 where id>$id;
However, that is a bad idea usually. If you have dependencies in other tables based on that id you will create anomolies.
July 11th, 2000, 06:05 AM
>However, that is a bad idea usually. If you >have dependencies in other tables based on >that id you will create anomolies.
Thats true I never thought of that!, thank you.