I have a working INSERT INTO SELECT query which inserts records into a new table based on the results of the select. Simple.
INSERT INTO my_table (a, b, c)
SELECT a, b, c FROM my_table
WHERE x=y;
How do I get the newly created primary key IDs from the INSERT part of this query so that I can use them to update another table? (The primary key is the only unique reference)
I have read that INSERT INTO SELECT only supports inserting into one table per query, so that’s out of the question. How can this be accomplished (using MyISAM engine)?
YOu can select your data in a temp Table, then run cursor on that while inserting rows u ll have PK