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'
Please see here https://stackoverflow.com/questions/69716876/mysql2-nodejs-pass-table-name-as-variable-right-syntax-to-use-near?noredirect=1#comment123231095_69716876
The use of variable for table name is not working