shane85 Posted April 3, 2010 Share Posted April 3, 2010 hey guys so ive made a db and made it so each row as a product_id number...which auto increases for each time something is added. However, ive done like 50 test entries so my numbers go from 1,2,3,56,57,58 etc I went in and edited them all so they are all in order and I have about 23 entries. However when I add the next one it goes to 59...so something is still telling it theres that many entries. How do I make it so the next entry will be after the last product_id number? Quote Link to comment https://forums.phpfreaks.com/topic/197484-hmmquestion-on-mysql-db-id-number-auto_increment/ Share on other sites More sharing options...
ialsoagree Posted April 3, 2010 Share Posted April 3, 2010 ALTER TABLE table_name AUTO_INCREMENT = x Where x is the new auto_increment value (the 1st number that will be given to the next record). Quote Link to comment https://forums.phpfreaks.com/topic/197484-hmmquestion-on-mysql-db-id-number-auto_increment/#findComment-1036524 Share on other sites More sharing options...
jcbones Posted April 3, 2010 Share Posted April 3, 2010 Instead of x, just use number 1. Mysql will auto adjust to the next available increment. Quote Link to comment https://forums.phpfreaks.com/topic/197484-hmmquestion-on-mysql-db-id-number-auto_increment/#findComment-1036552 Share on other sites More sharing options...
shane85 Posted April 3, 2010 Author Share Posted April 3, 2010 where would I put this statement? I dont use it in any of my querys accept when the db is first created. Quote Link to comment https://forums.phpfreaks.com/topic/197484-hmmquestion-on-mysql-db-id-number-auto_increment/#findComment-1036559 Share on other sites More sharing options...
ialsoagree Posted April 3, 2010 Share Posted April 3, 2010 Yes, this change should only be run once. Either create a unique PHP file to run it, or run it on the command line when connected to MySQL or through software that manages a MySQL database like phpMyAdmin or GUI software that allows you to run SQL on the database. Quote Link to comment https://forums.phpfreaks.com/topic/197484-hmmquestion-on-mysql-db-id-number-auto_increment/#findComment-1036564 Share on other sites More sharing options...
shane85 Posted April 4, 2010 Author Share Posted April 4, 2010 perfect, ty! Quote Link to comment https://forums.phpfreaks.com/topic/197484-hmmquestion-on-mysql-db-id-number-auto_increment/#findComment-1036632 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.