Currently I am working on my Web site Frontend: Vue Backend: Node.js
I am trying make a function which allows managers to delete user.
While making some SQL code for delete user information, I comes to my mind that
I cannot expect number of user deleted by manager..
It could be one, two or more.
So, please advice me how to tackle with this situation. I want to finish this in a single SQL sentence.
Thank you very much.
I have tried to make SQL codes like this
DELETE FROM user_table WHERE user_id = ${1} AND ${2} AND ${3} or more.....
I want to know a condition use for unexpected number of user Input
CodePudding user response:
use IN
let user_ids_to_delete = req.body.user_ids; //example : [1,2,3,4]
let query = `DELETE FROM user_table WHERE user_id IN(${user_ids_to_delete});`