Update in mysql nodejs

Update in mysql nodejs

var mysql = require(‘mysql’);

var con = mysql.createConnection({
host: “localhost”,
user: “root”,
password: “”,
database: “nodejs”
});

con.connect(function(err) {
if (err) throw err;
var sql = “UPDATE customers SET address = ‘Raipur’ WHERE address = ‘Highway 37′”;
con.query(sql, function (err, result) {
if (err) throw err;
console.log(result.affectedRows + ” record(s) updated”);
});
});

Leave a Reply