I'm trying to select data already in the database and insert it into two tables using the generated ID from table one.
table1 contains configuration options,
table2 contains pricing data.
Table2 uses the auto ID from
I have all these products in
Table1 and I have to use the same config options in another group in that table, but WHMCS doesn't have copy for config options.
I was thinking of going into the table and running a select query like so:
INSERT INTO tblproductconfigoptionssub ( id , configid , optionname , sortorder , hidden ) SELECT NULL , 76 , optionname , sortorder , hidden FROM tblproductconfigoptionssub WHERE configid = 41
That works for data from the first table, by selecting all records from config group id 41 and reinsert them, except now they are linked to config group 76.
Table2 contains the pricing data and it has a column called
relid that is linked to the ID generated from tblproductconfigoptionssub above.
Table2 already has pricing for the items in table1 under their original IDs. The records from Table2 would have to be copied, but with the new IDs generated by the query above.
How do I modify the statement above to insert the new data into Table2, along with the prices?
I don't really want to do a PHP script for this. However, I think I need to make a MySQL function to select all items from config group 41 and then store values in variables. Then insert into two tables.
Is there a way to do this with