escape nodejs mysql code example
Example: node js mysql escape string
// Escape values:
let escaped = mysql.escape('myString');
// or
mysql.query(
"SELECT * FROM `table` WHERE `str1`=? AND `str2`=?",
['myString1', 'myString2'],
(err, result)=>{}
);
// Escape identifiers:
mysql.query(
"SELECT * FROM ??", // note the double ?
['tablename'],
(err, result)=>{}
);