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); }); });