我想这样做:
var ids = '1,2,3';
connection.query('SELECT * FROM table WHERE id IN (?)', ids, function(err, rows, fields) {
if (err) throw err;
console.log('The solution is: ', rows[0].id);
});不幸的是,它没有给出正确的结果。
在跟踪node-mysql时,我发现查询被解释为:
SELECT * FROM table WHERE id IN ('1,2,3')而不是:
SELECT * FROM table WHERE id IN (1,2,3)你知道我怎么才能做到这一点吗?
发布于 2013-07-03 16:00:15
在几秒钟后发布问题,我已经弄明白了。
var ids = [1,2,3];
connection.query('SELECT * FROM table WHERE id IN (?)', ids, function(err, rows, fields) {
if (err) throw err;
console.log('The solution is: ', rows[0].id);
});https://stackoverflow.com/questions/17442588
复制相似问题