Assuming your string is cleared, I would implode string in the array and use implode to create the statement. You should not store multiple values ββin a row. What are arrays for?
$string = 'US|UK|AUS|CA'; $string = explode('|', $string); $stmt = "SELECT ... country IN ('" . implode("', '", $string) . "')";
Gives out
SELECT ... country IN ('US', 'UK', 'AUS', 'CA')
source share