I have a get API in nodejs , which gets string of variables as query string ( delimited by ",") as follows
const mac = req.query.mac;
console.log(mac); // 00:11:22:33:FF:EE,11:11:22:33:FF:EE
var sql = mysql.format("SELECT * FROM user_email WHERE macId IN ?",[mac]);
connection.query(sql, function(err, row) ...{ ... .. }
But i am getting errors
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''00:11:22:33:FF:EE,11:11:22:33:FF:EE'' at line 1",
sqlState: '42000',
index: 0,
sql: "SELECT * FROM user_email WHERE macId IN '00:11:22:33:FF:EE,11:11:22:33:FF:EE'"
}
Someone please help !!
''00:11:22:33:FF:EE,11:11:22:33:FF:EE''additional quote is getting addedmysql.escape()try with this ?