-4

I've got the table with auto_increment ID column and i want to add another column, which would has copied numbers from ID column ( for example named copied_ID), so i want to have two the same colmuns, one of them auto_increment. before_photo I've tried:

insert into my_table (copied_ID) select ID from my_table;

But then i've got: after_photo

s7e0n5g1a
  • 47
  • 1
  • 7

1 Answers1

0

If you want to add another column:

-- Add the column to the table, if necessary
alter table my_table add column copied_id int; 

-- Update the table
update my_table 
    set copied_id = id;

insert inserts new rows. You want to add a new column.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786