Nhận máy chủ Node của riêng bạn
 var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", user: "myusername", password: "mypassword", database: "mydb" }); con.connect(function(err) { if (err) throw err; var sql = "SELECT users.name AS user, products.name AS favorite FROM users LEFT JOIN products ON users.favorite_product = products.id"; con.query(sql, function (err, result) { if (err) throw err; console.log(result); }); });

[
{ người dùng: 'John', yêu thích: 'Thiên đường sô cô la' },
{ người dùng: 'Peter', yêu thích: 'Thiên đường sô cô la' },
{ user: 'Amy', favorite: 'Quả chanh ngon' },
{ người dùng: 'Hannah', yêu thích: null },
{ người dùng: 'Michael', yêu thích: null }
]