Want to select MySQL rows where column value is 11 or 12 or 23. Tried with such code
$query_select_all = 'SELECT * FROM 2_1_journal WHERE CAST(EntryId AS UNSIGNED) IN (?)';
$sql = $db->prepare($query_select_all);
$data1[] = '11, 12, 23';
$sql->execute($data1);
But the code select only rows where column value is 11 (the first value from $data1[] = '11, 12, 23';
)
Tried without ?
and works as necessary.
Here is statement without ?
(positional placeholder)
$query_select_all = 'SELECT * FROM 2_1_journal WHERE CAST(EntryId AS UNSIGNED) IN (11, 12, 23)';
$sql->execute();
The statement works as expected (select rows where EntryId
is 11 or EntryId
is 12 or EntryId
is 23.
Where is error in the first code (with ?
)?