I want to execute a MYSQL query:
INSERT INTO taskattempts (taskID) VALUES (_);
which I want to execute multiple times, once for each result of the query:
SELECT id FROM tasks WHERE stageID = 1;
using the resultant id from the second query as the value of taskID in the first.
Is there any way to do this using a single MySQL query? A PHP loop running multiple queries seems dreadfully inefficient.
*EDIT *
I actually need to fill in multiple columns, two static and one with the subquery. I found that INSERT INTO taskattempts (stageAttemptID, taskID, complete) SELECT 0, id, 5 FROM tasks WHERE stageID = 5; works, but wonder whether this is kosher. Also, in the interest of knowledge, can you fill in different columns with different queries?