MySQL操作数应包含3列

时间:2017-03-29 06:45:36

标签: mysql node.js express

let ids = [100,200,300]
let scond_ids = [100,200,300]
let name = ["a","b","c"]

connection.query("SELECT * FROM table_name WHERE (id,second_id,name) in ((?),(?),(?))", [ids,second_ids,name], (err,result,field) => {
    if(err)console.log(err)
});
  

操作数应包含3列

当我使用node.js执行此操作时出现此错误 请告诉我如何解决!!

1 个答案:

答案 0 :(得分:3)

我从未见过这样的语法。我会改为声明:

SELECT * 
FROM table_name 
WHERE id in ? and second_id in ? and name in ?

此外,如果您使用预准备语句,则不应在函数中添加括号。