我想对MYSQL表进行批量插入。根据这个post,我使用的是2D数组。但是,我一直收到MYSQL语法错误。有人能指出我吗?
错误:
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'
我在db中有五列,其中有一个自动递增Id
,update_date
和create_date
,我没有将其放入insert
查询中。对于update_date
和create_date
,我将其设置为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();
});
答案 0 :(得分:0)
'默认'您的字段定义中缺少?
update_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP