Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

insert multiple Row in SQL database with NodeJS

// 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");
    });
};
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #insert #multiple #Row #SQL #database #NodeJS
ADD COMMENT
Topic
Name
7+9 =