I'm using node-mysql in my node.js server.
Problem is, I'm trying to pass a javascript variable into my WHERE sql statement and it's not picking it up (for obvious reasons). I've looked through node-mysql documentation, including the SET method, however this won't work as the variable needs to come from javascript code as i would like it to be dynamically inputted by the user.
Any ideas? Code below..
api.js
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'my server',
user: 'username',
password: 'password',
database: 'fruits'
});
connection.connect()
var blueberriesWeight = "100"
connection.query('SELECT fruit_price FROM fruit WHERE fruit_weight = blueberriesWeight',
function(err, result){
console.log(result)
console.error(err)
})