Stromgren Stromgren - 10 months ago 47
MySQL Question

Executing 'where in' statement with Mysqljs\mysql

I'm using mysqljs\mysql in a Node application and I've run into some trouble performing statements with 'in' clauses.

Under paramater escaping, the documentation states that:

Arrays are turned into list, e.g. ['a', 'b'] turns into 'a', 'b'

Escaping query values

But when i try something like this:

var sql = "SELET * FROM table WHERE name IN (?)";
var params = ['a', 'b', 'c'];
console.log(mysql.format(sql, params));

I get a query containing only the first value of the array:

"SELET * FROM table WHERE name IN ('a')"


Try this :

var params = [['a', 'b', 'c']];