Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Deleting multiple rows given an array of values in MySQL with Node.js and Express.js

I'm trying to delete multiple rows in a MySQL table that match up with multiple values in an array.

Here's an example of my attempt:

const query = 'DELETE FROM example_table WHERE (a_id AND b_id AND c_id) IN ?';
const values = [
      { a_id: 1, b_id: 2, c_id: 3},
      { a_id: 4, b_id: 5, c_id: 6},
      { a_id: 7, b_id: 8, c_id: 9}
     ];

connection.query(query, values, function(err, results) {
     // do something
});

So, I'm essentially trying to find the rows whose column values matchup with the values in the objects in my array. I think my problem is that my query statement is not necessarily comparing the values at all, or that my logic in tackling this problem is not correct.

What should the query statement be, or should I be doing this another way?

Thank you.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

const query = 'DELETE FROM example_table WHERE a_id in (?) and b_id in (?) AND c_id IN (?)';
const values = [
      { a_id: 1, b_id: 2, c_id: 3},
      { a_id: 4, b_id: 5, c_id: 6},
      { a_id: 7, b_id: 8, c_id: 9}
     ];

connection.query(query, values, function(err, results) {
     // do something
});
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!