Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Mysql + Node.Js unexpected number of Delete Condition

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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});`
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading