节点JS mysql用数组数组删除多行

我需要做一个能够从我的表中删除多行的查询。 为了做到这一点,我已经在数组中创build了一个需要传递给该查询的值的数组。 这是我的代码:

var deleteRooms = [ [ 3, 23 ], [ 4, 23 ], [ 5, 23 ], [ 2, 23 ]]; connection.query("DELETE FROM rate_plans_rooms WHERE room_id = ? AND rate_plan_id = ? ", [deleteRooms],function(err,results){ if(err){return console.log(err)} else { console.log('sended'); } }); 

但每次我收到这样的错误:

 { Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' (4, 23), (5, 23), (2, 23) AND rate_plan_id = ?' at line 1 

我如何解决这个问题,并正确地发送我的查询?

你的问题的解决scheme是在你的查询中使用“IN”:

 var deleteRooms = [[3,23],[4,23],[5,23], [2,23]]; connection.query("DELETE FROM rate_plans_rooms WHERE (room_id, rate_plan_id) IN (?)", [deleteRooms],function(err,results){ if(err) return console.log(err) else console.log('sended'); });