How can multiple statement option be used in just one query MYSQL

22 Views Asked by At

I am not good at English but I hope you understand what my problem is. I'm using the node mysql2 package to handle the connection to the database. and for security i have not enabled the "multipleStatement" option, but in a specific case I want to perform a query using multiple statements and for that I tried the following:-

const [result] = await connection.query({sql:"SELECT * FROM table1; SELECT * FROM table2;", multipleStatement:true});

but it did not work and throws an error as follows :-

code: 'ER_PARSE_ERROR',
errno: 1064,
sql: 'SELECT * FROM table1; SELECT * FROM table2;',
sqlState: '42000',
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' SELECT * FROM table2;' at line 1"

i do not want to set this option globally "multipleStatement". i want just enable it for a specific query.

0

There are 0 best solutions below