demo_db_where_s.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 where the address starts with an "S":*/ con.query("SELECT * FROM customers WHERE address LIKE 'S%'", function (err, result) { if (err) throw err; console.log(result); }); });
C:\Users\My Name>node demo_db_where_s.js
[
{ id: 8, name: 'Richard', address: 'Sky st 331'},
{ id: 14, name: 'Viola', address: 'Sideway 1633'}
]