Check out example codes for "node js mysql query". It will help you in understanding the concepts better.

Code Example 1

var mysql = require('mysql');

var conn = mysql.createConnection({
  host: "localhost",
  user: "yourusername",
  password: "yourpassword",
  database: "mydb"
});

conn.connect((err)=>{
  if (err) throw err;
  
  conn.query("SELECT * FROM customers", (err, result, fields)=>{
    if (err) throw err;
    console.log(result);
  });
});

Code Example 2

con.connect(function(err) {
  if (err) throw err;
  console.log("Connected!");

   
  con.query(sql, function (err, result) {
    if (err) throw err;
    console.log("Result: 
  " + result);
  });
});

Learn ReactJs, React Native from akashmittal.com