Node.js sqlite3 IN operator

后端 未结 2 808
野的像风
野的像风 2021-02-14 07:25

So I am currently trying to make a query in Node.js:

// friends is an array object
db.all(\'SELECT email \' +
       \'FROM users\' +
       \'WHERE email in ?\'         


        
相关标签:
2条回答
  • 2021-02-14 08:02

    Slight variation on asbel's great answer:

    db.all(
        `SELECT email FROM users WHERE email in (${ friends.fill('?') })`, 
        friends, 
        callback
    );
    
    0 讨论(0)
  • 2021-02-14 08:03
    db.all('SELECT email ' +
           'FROM users' +
           'WHERE email in ( ' + friends.map(function(){ return '?' }).join(',') + ' )', 
           friends, 
           function(err, rows) {
               if (!err) {
    
    0 讨论(0)
提交回复
热议问题