Node-mysql2: "user defined variable" is failing with syntax error.

Created on 29 Nov 2016  路  2Comments  路  Source: sidorares/node-mysql2

I am using node 5.0.0 along with the node module mysql2 - 1.0.0-rc.11. Everything is working perfectly fine except when I try to use the user defined variables.

Example :

SET @user := 123456;
SELECT * FROM users WHERE user = @user;

The above simple query is throwing syntax error at my end. I am sure that, the syntax is a valid one. So I am wondering what may be the cause for this issue?

Doesn't the node module mysql2 - 1.0.0-rc.11 have support for SET yet? I have scanned the [document1, document2] thoroughly, I couldn't able to find the syntax support list. Can anyone help me to understand what's going wrong with this?

question

All 2 comments

@laraprabhu if you pass this as a single query you have to set multipleStatements flag to true - see https://github.com/mysqljs/mysql#multiple-statement-queries

@sidorares Thank you for your quick reply. The configuration that you have suggested, has fixed the bug in our application.

Was this page helpful?
0 / 5 - 0 ratings