Answer the question
In order to leave comments, you need to log in
To form a long query in the database?
DB - MySQL. Hundreds of rows need to be inserted in a single query, and the third parameter must be taken from an adjacent table. How to generate a query through a loop?
var sql = "INSERT INTO person (id, name, school) VALUES (?, ?, (SELECT id FROM school WHERE number='?'))";
Answer the question
In order to leave comments, you need to log in
INSERT INTO person (id, name, school)
SELECT id, ... AS name, ... AS school FROM school WHERE ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question