I'm a total newbie when it comes to databases and I've created a database for an arcade that has 0 as the id for all games. How can I make this value incremental so that each game has a different id? Please note that the games have already been imported into the database and dropping the table is not an option. I'm using phpmyadmin. step by step instructions would be much appreciated.
In phpmyadmin, go to the table question, in the structure tad click change on the id field. Click the A_I check box. If you want the id field to start from a number other than one, type in the SQL box: ALTER TABLE tablename AUTO_INCREMENT = number you want it to start from;
Thank you! I tried it and it says "#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key" I don't have anything defined as the primary key. I tried setting the column "id" as the primary key, but since the table is already full, it says "duplicate entry 0 for key 1". What do I do?
Define your primary key and it should work. Instead of click change on the id field, just click primary (should have a key next to it).
I tried.. that's when it says "duplicate entry 0 for key 1". Note that all the fields in the table "id" have a 0 in them.
That made them all 1 I also tried UPDATE tablename SET id = id + 1 and that made them all 2. Will tinker a bit more.
I can provide you the php code which will makes ids incremental, do you have any column which identify the row as unique( Such as gameid)?