1、bulk insert:
碰到自增的主键,需要列出插入的column,为了去除主键
普通insert,碰到自增的主键,不用列出column也行。
insert into set为mysql的扩展语法,适合插入单行
insert into value 为标准SQL语法,能一次插入多行数据
示例1:
tablename ??
var row1 = [1, 2];
var row2 = [3, 4];
var set = [row1, row2];
var table_name = 'tablename';
var value = [table_name, set];
conn.query('INSERT INTO table ?? VALUES ?', values)
示例2:
var row1 = [1, 2];
var row2 = [3, 4];
var set = [row1, row2];
var value = [set];
conn.query('INSERT INTO table temp VALUES ?', values)
示例3:
var sql = 'insert into '+config.wine_set_t+' (wine_id, set_id, wine_num) VALUES ? ';
var row1 = [10, 10, 10];
var row2 = [10, 10, 10];
var set = [row1, row2];
mysqlUtil.query(sql, [set], function(err, result) {