0

Is it possible with the node mysql library to bulk insert using a sub query?

Something like

var data = [[1,2],[3,4]];

var qry = 'insert into tableA select ? from tableB where id = ?';

connection.query(qry,[data]);
Michael
  • 2,825
  • 3
  • 24
  • 30

1 Answers1

0

Specify the column on insert and match that column to the sub query.

INSERT INTO Table1 (Column1, Column2)
SELECT column3, column4
FROM Table2 AS t2
WHERE t2.id = ?;
Wesgur
  • 3,140
  • 3
  • 18
  • 28