I want to do a bulk insert to MYSQL table. According to this post, I'm using a 2D array. However, I kept getting MYSQL Syntax errors. Can anyone point me out?
Error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL'
I have five columns in db, which has an auto-incrementing Id
, update_date
and create_date
which I didn't put in the insert
query. For update_date
and create_date
I set it to on update CURRENT_TIMESTAMP
var insert = 'INSERT INTO table2 (link, text) VALUES ?';
var res = [['www.google.com', 'google'],['www.bing.com', 'bing']];
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'XXX',
database: 'dbname'
});
connection.connect();
connection.query(insert, [res], function(err) {
if (err) {
console.log(err)
connection.end();
throw err;
}
connection.end();
});