当我尝试使用javascript将批量数据插入mysql时,我收到以下错误:
ER_WRONG_VALUE_COUNT_ON_ROW: Column count doesn't match value count at row 1
var users = [
{"name" : "Person1", "id" : 1, "photo" : "/images/1.jpg"},
{"name" : "Person2", "id" : 2, "photo" : "/images/2.jpg"},
{"name" : "Person3", "id" : 3, "photo" : "/images/3.jpg"},
]
var insert_users = (users) =>
sql.autoconnect().query(
"INSERT INTO users (name, id, photo) VALUES (?, ?, ?)", users,
function(err) {
if (err) throw err;
sql.autoconnect().end();
}
);