I have multiple numeric values which I can express as either an array, or as a comma-separated string. For each of these values I would like to select the corresponding database row. Is it possible to do this in one query?
// data examples
$array = array(3, 6, 200); // or more values
$string = '3,6,200' ; // or more values
I can do the following query for each value, to get a field from the table:
SELECT email FROM table WHERE id='$array_value';
But how can I get this in one query?
You should use
INoperator. If$datais either array or comma separated list of numbers (string), do:Only do this if you are sure that elements in the array are safe.
If you have to make your data safe you can do this
Or if you are expecting integer values, just go with: