NodeJs Mysql Select

Lets create a file “node-select.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 = "select * from emp";
con.query(sqlQuery, function (err, result) {  
if (err) throw err;  
console.log(result);  
});  
});

Below SS shows Output of this program.

node mysql select query

Below SS shows output from Mysql.

node mysql select output

Subscribe Now