alter table mytable add id int(11) primary key auto_increment;
Then you'd really want it to be the first column on the left, not that it has to be, it's just a bit of a standard. Simply put, you create a temporary table, select the fields in the order you want them, insert, drop old table, rename temp table. From the documentation,
1. Create a new table with the columns in the new order. 2. Execute this statement: mysql> INSERT INTO new_table SELECT columns-in-new-order FROM old_table; 3. Drop or rename old_table. 4.Rename the new table to the original name: mysql> ALTER TABLE new_table RENAME old_table;
If you select data by column-name, everything will function as it did, if you select anything by array index you will have to shift your array over by one.
old: title|content $row=mysql_fetch_array($result); // These are equivalent $title = $row; $title = $row['title'];
new: id|title|content $row=mysql_fetch_array($result); // These are equivalent $title = $row; // id is now 0 $title = $row['title'];