📜  使用 NodeJS 在 SQL 数据库中插入多行 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:27.733000             🧑  作者: Mango

代码示例1
// Function to insert multiple Row in database
let multipleRowInsert = () => {
  
    // Query to insert multiple rows
    let query = `INSERT INTO gfg_table 
        (name, address) VALUES ?;`;
  
    // Values to be inserted
    let values = [
        ['Amit', 'Yellow Park'],
        ['Rishi', 'Park 38'],
        ['Akash', 'Central st 954'],
        ['Pratik', 'Road 989'],
        ['Mangesh', 'Sideway']
    ];
  
    // Executing the query
    db_con.query(query, [values], (err, rows) => {
        if (err) throw err;
        console.log("All Rows Inserted");
    });
};