Closed dabaii closed 3 years ago
Hi @dabaii this is because in your first example, you have a list of numbers, but in your second, you have a single string. You can see the same results in the second if you used strings in the first like
SELECT * FROM shop_product WHERE productid in('1,2,3,4,5')
You want to use an array of numbers in your values, like the following:
connection.query('SELECT * FROM shop_product WHERE productid in(?)`,[[1,2,3,4,5]] ,(error, results, fields)=> {...})
👍
// code 1 connection.query(SELECT * FROM shop_product WHERE productid in(1,2,3,4,5)` ,(error, results, fields)=> {...})
// results length is 5
//code 2 connection.query(SELECT * FROM shop_product WHERE productid in(?)`,["1,2,3,4,5"] ,(error, results, fields)=> {...})
// results length is 1
The results are different???