I use the following code to copy from one table directly into another:
$transfer = $db->exec("INSERT INTO table2 SELECT * FROM table1 WHERE groupname = '$gname'");
The issue I have, however, is the ID field of both tables do not necessarily match (both auto-increment) and at times this may mean one temporary's tables ID# is higher than the final table.
I use php, pdo and mysql.
Is there any way around this?