$ids = array(1, 2, 3, 4);
$ids = join(', ', $ids);
$query = "SELECT * FROM business WHERE business_id IN ($ids)";
// $query => SELECT * FROM business WHERE business_id IN (1, 2, 3, 4)
Peringatan injeksi SQL biasa masih berlaku, Anda mungkin ingin mengulang id terlebih dahulu untuk memvalidasi atau menghindarinya. Juga, jika Anda mengharapkan string alih-alih angka, gunakan ini:
$ids = array('a', 'b', 'c', 'd');
$ids = join("', '", $ids);
$query = "SELECT * FROM business WHERE business_id IN ('$ids')";
// $query => SELECT * FROM business WHERE business_id IN ('a', 'b', 'c', 'd')