Join in node js mysql

var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", user: "yourusername", password: "yourpassword", database: "mydb" }); con.connect(function(err) { if (err) throw err; var sql = "SELECT users.name AS user, products.name AS favorite FROM users JOIN products ON users.favorite_product = products.id"; con.query(sql, function (err,…

0 Comments

Limit in node mysql

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 = "SELECT * FROM customers…

0 Comments

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…

0 Comments

Delete query in node js mysql

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 = "DELETE FROM customers WHERE…

0 Comments

Orderby condition in node js mysql

A. asc order 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…

0 Comments

Where condition in node js mysql

A. Fetch data with where() 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…

0 Comments

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 *…

0 Comments