1权逗、bulk insert:
碰到自增的主鍵,需要列出插入的column冤议,為了去除主鍵
普通insert斟薇,碰到自增的主鍵,不用列出column也行恕酸。
insert into set為mysql的擴展語法堪滨,適合插入單行
insert into value 為標(biāo)準(zhǔn)SQL語法,能一次插入多行數(shù)據(jù)
示例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) {