使用MySQL IN()与PHP和PDO [重复]

This question already has an answer here:

I'm developing a web service and one of the parameters it takes is a list of device IDs (energy_mon_id). The list is comma separated e.g. 0,1,2 (the other two parameters it takes are dateFrom and dateTo).

My prepared statement looks like this:

$this->sql = "SELECT $vars FROM $table "

                . "WHERE energy_mon_id IN(:energy_mon_id) AND CONCAT(date, ' ', time) "
                . "BETWEEN :dateFrom AND :dateTo "
                . "$group ORDER BY $orderBy $limit";

The problem is that instead of recognising these as individual comma separated characters it's being interpreted as a complete string (I think). I tried to follow this post

I have searched around and found the exact same solution being provided (it seems to work for everyone else but me). I'm quite puzzled, never have I had to directly ask a question myself, so this is my first post!

Thanks for the help in advance.

</div>

Thanks for the comments they pointed me to a suitable post with the answer. However, just to simplify for anyone that may be having a similar issue, this simple fix worked...

instead of using:

WHERE energy_mon_id IN(:energy_mon_id)

I used:

WHERE find_in_set(energy_mon_id, :energy_mon_id)