Incompatibility with Node MySQL, mysql2 nodejs pass table name as variable / right syntax to use near '??'
dragonfire2018 opened this issue · 2 comments
dragonfire2018 commented
The use of variable for table name is not working
tableName = "some_table"
id = "some_id";
const readForwardedMessageDetails = pool.execute('SELECT * FROM ?? WHERE `id` = ? LIMIT 1',
[tableName, id],
function(err, row) {
if (err) {
console.log(err)
return
} else {
}
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlState: '42000',
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 '?? WHERE `id` = ? LIMIT 1'
at line 1 ",
sql: 'SELECT * FROM ?? WHERE `id` = ? LIMIT 1'
dougwilson commented
Hello, sorry for your issue, but you issue is unrelated to this module. You are using a module named mysql2, which is different from this one.
dragonfire2018 commented
sorry posted accidentally... have reposted to mysql2....