NodeJs Mysql Update

Lets create a file “node-update.js” with below code
var db = require('mysql');  
var con = db.createConnection({  
host: "localhost",  
user: "root",  
password: "password" ,
database : "Student" 
});  
con.connect(function(err) {  
if (err) throw err;  
console.log("Connected!");  
var sqlQuery = "update emp set name=’xyz’ where id=1";
con.query(sqlQuery, function (err, result) {  
if (err) throw err;  
console.log("Rows Updated");  
});  
}); 

Below SS shows Output of this program.

node mysql update query

Below SS shows output from Mysql.

node mysql update output

Subscribe Now