demo_db_where.js:
var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", user: "myusername", password: "mypassword", database: "mydb" }); con.connect(function(err) { if (err) throw err; /*Select all customers with the address "Park Lane 38":*/ con.query("SELECT * FROM customers WHERE address = 'Park Lane 38'", function (err, result) { if (err) throw err; console.log(result); }); });
C:\Users\My Name>node demo_db_where.js
[
{ id: 11, name: 'Ben', address: 'Park Lane 38'}
]