Skip to content
Advertisement

MariaDB, How to copy existing records using insert?

I have a lot of existing records which I want to copy using an INSERT, for example if I have a query:

The common key is biDataset, the primary key in this table is biPK which is auto incremented on each insert. Here is the table structure:

What I want to do is copy all the records that exist where biDataset is 9, creating new records, I need to be able to specify the new biDataset too, 15 to use for all copies instead of 9.

I’ve tried:

This results in:

Advertisement

Answer

The solution was to modify the table structure to:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement