2

Well, this is actually a simple question but I can't seem to find a proper answer anywhere else.

I have an id column. The column is empty, but the table contains approximately 11,000 rows. I want the empty id column to be used as the Id. What PHP/SQL code can I run to fill those 11,000 rows of that id column? (like so: '1, 2, 3, 4... ect')

  • 1
    Drop the existing column then follow this to add a new one: http://stackoverflow.com/questions/9070764/insert-auto-increment-primary-key-to-existing-mysql-database/9070808#9070808 – Michael Berkowski Jan 02 '14 at 01:58
  • 'int' and your command doesn't work. – Eli Rotenberg Jan 02 '14 at 01:59
  • 7
    Actually, you don't even need to drop the old column. You can `MODIFY` it in place with `ALTER TABLE tbl MODIFY id INT PRIMARY KEY AUTO_INCREMENT;` and the column will be filled. – Michael Berkowski Jan 02 '14 at 02:00

0 Answers0