In MySQL, can I copy one row to insert into the same table?

后端 未结 26 2380
-上瘾入骨i
-上瘾入骨i 2020-11-27 09:56
insert into table select * from table where primarykey=1

I just want to copy one row to insert into the same table (i.e., I want to duplicate an ex

26条回答
  •  猫巷女王i
    2020-11-27 10:30

    I used in my Koha database to insert duplicate items with the 'C' prefix in barcode column:

    INSERT INTO items (`biblionumber`, `biblioitemnumber`, `barcode`, `dateaccessioned` ) SELECT `biblionumber`, `biblioitemnumber`,  CONCAT('C',`barcode`), `dateaccessioned` FROM `items` WHERE barcode='14832';
    

提交回复
热议问题