Select data from mysql database using node js

Select data from mysql database using node js

A. Fetch data without condition

var mysql = require(‘mysql’);

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

con.connect(function(err) {
if (err) throw err;
con.query(“SELECT * FROM customers”, function (err, result, fields) {
if (err) throw err;
console.log(result);
});
});

 

 

Leave a Reply