Copy rows from the same table and update the ID column

前端 未结 8 457
情歌与酒
情歌与酒 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-01 03:05

    INSERT INTO ProuctDefinition (ProdID, Definition, Desc)
    SELECT
      xxx, Definition, Desc
    FROM
      ProductDefinition
    WHERE
      ProdID = yyy
    

    The xxx is your new ProdID and the yyy is your old one. This also assumes that DefID is automagically populated on INSERT.

提交回复
热议问题