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.
via R. T.
No comments:
Post a Comment