Multi-Statement Query Support in Node-MySQL
In Node.js, the question arises when executing multiple SQL statements in a single query using the node-mysql package.
The code provided by the user attempts to delete records from four tables using半彩色(;)分開語句。但是,這導致錯誤指出SQL語法中存在錯誤。
node-mysql文檔最初出於安全原因最初禁用多個語句支持,因為它可能導致SQL注入攻擊。要啟用此功能,您需要在創建連接時將倍增設置設置為true:var connection = mysql.createconnection({{multipleStatement:true});
通過執行一個element and ement element and and e ementai語句。var connection = mysql.createConnection({multipleStatements: true});在您的情況下,通過將乘法設置為true,您的初始代碼應在單個查詢中成功執行四個刪除語句,從而消除了對多個查詢的需求並提高代碼效率。
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3