I have a simple Node.js application that executes the following query:
select * from User where userid in (?)
The userids I get are from a JSON array sent from the client side. How can I use that in this select query? I tried:
If you are using node module like mysql this can be accomplished with the following:
const query = "SELECT * FROM User WHERE userid IN (?);";
const data= ["a", "b", "c"];
conn.query(query, [data], function (err, results) {});
According to the documentation, "Arrays are turned into a list, e.g. \['a', 'b'\]
turns into 'a', 'b'
".