I have an array of variable length and i want to pass the array into mysql get query.
var ids = [1, 3, 7, 8]
And my query is
return Connection.query("select student from registrations where id in (?)", [ids], callback);
Is it possible?
After several attempts such as mapping and spread operator used directly on the array which is passed in, I use literal template to solve that, but it might has some potential security risk in SQLInjection.
return Connection.query(`select student from registrations where id in (ids.toString())`, callback);
Yes the query will works.
get_source_pass_oppartner_ridePoints:
'SELECT * FROM ride_root WHERE rideId in (?)',
return database.query( sql.get_source_pass_oppartner_ridePoints, [rideIds] )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.