Copy rows from the same table and update the ID column

前端 未结 8 454
情歌与酒
情歌与酒 2021-02-01 02:09

I have the following table

\"alt

I have inserted Product B to it and it gives me an ID of 15

8条回答
  •  死守一世寂寞
    2021-02-01 02:39

    This will work with any column you choose. Not just primary key/ID.

    INSERT INTO TableName (Column1, CustomID, Column3, Column4, Column5)
    SELECT Column1, 'NewValue', Column3, Column4, Column5 FROM TableName
    WHERE CustomID='OrigValue'
    

提交回复
热议问题