Node.js Tutorial – Update Record into MySQL Table

The tutorial provides the node.js integration with MySQL for inserting record into the mysql table. The tutorial provides the steps on how to insert new record into mysql table using node.js application .

Update Record into MySQL Table using node.js

The MySQL uses ‘UPDATE ‘ statement for updating records into mysql table. Ensure that you have the mysql table with records before proceeding with the table record updation process.

var mysql = require('mysql');  
var con = mysql.createConnection({  
  host: "localhost",  
  user: "root",  
  password: ""  ,
  database: "oracleappshelpDB"
}); 
con.connect(function(err) {  
if (err) throw err;  
var sql = "UPDATE oracleappshelpusers SET firstName = 'Mihika' WHERE firstName = 'Mohit'";  
con.query(sql, function (err, result) {  
if (err) throw err;  
console.log(result.affectedRows + " record(s) updated");  
});  
});