Slip 13 - B) Create a Node.js Application that Update Marks of given student Rno in “student" table and display the result.

Solution:

var mysql = require('mysql');

var con = mysql.createConnection({

host: "localhost",

user: "root",

password: "",

database: "student"

});

con.connect(function(err) {

if (err) throw err;

var sql = "UPDATE student SET Marks = 90 WHERE Roll__num = 1";

con.query(sql, function (err, result,display) {

if (err) throw err;

console.log(result.affectedRows + " record updated");

});

con.query("SELECT *, name FROM student", function (err, result, fields) {

if (err) throw err;

console.log(result);

});

});

Post a Comment

0 Comments