The following query is supposed to return three rows, but it returns only one:
$sql = $dbh->prepare("SELECT * FROM table_name WHERE state = ? AND id IN(?) AND status IN(?)");
$sql->execute(array(1, '1,2,3', '1,2,3'));
However, the same query executed without bound parameters as the argument to the IN()
function returns 3 rows, as it's supposed to:
$sql = $dbh->prepare("SELECT * FROM table_name WHERE state = ? AND id IN(1,2,3) AND status IN(1,2,3)");
$sql->execute(array(1));
Why does this happen, and how do I correctly bind 1,2,3
as the argument to IN()
?