Copy rows from the same table and update the ID column

前端 未结 8 458
情歌与酒
情歌与酒 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:48

    if you want to select all items (in condition the table not contains any primary keys)

    INSERT INTO [tabelName]
    SELECT  * FROM    [tabelName]
    WHERE  (YourCondition)
    

    in condition the table contains a primary keys, select only the columns that not primary key Like:

    INSERT INTO [tabelName]
    SELECT  col_1,col_2,col_n FROM    [tabelName]
    WHERE  (YourCondition)
    

提交回复
热议问题