In MySQL, you can use handy string function find_in_set()
to search for a value within a comma-separated string:
select * from recipes where find_in_set(id, ?) order by name
Note that I rewrote your statement as a parameterized query rather than munging values inside the query string. You do want to use these to make your code more efficient and safer.
Also, please keep in mind that this is rather inefficient way to proceed. It would be far beter to split your list into individual values, and to use in
:
where id in (12, 13, 34, 65, 11)
As a parameterized query:
where id in (?, ?, ?, ?, ?)