Copy rows from the same table and update the ID column

前端 未结 8 441
情歌与酒
情歌与酒 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 03:04
    insert into Table (DefID,ProdID,Definition,Desc)
           select DefID,15,Definition,Desc from Table where vo_user='jloe';
    
    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题