Node.js Tutorial: how to update mysql database records in node.js

The tutorial provides the node.js integration with MySQL to insert records into the mysql database. 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");