I have comma separated string data in my database field name 'status' for example:("2,5,6,9,16") and i have to search whose status is exactly '6'.
I am doing like this.
$offers = DB::query("select id,status from table WHERE (status LIKE '%6%')")->execute()->as_array();
$countOffer = 0;
if($offers){
foreach ($offers as $offer){
$checks= explode(',',$offer['status']);
foreach($checks as $check){
if($check == '6'){
$countOffer = $countOffer+1;
}
}
}
}
thanks in advance.