I have a 'list_table' table looks like:
id : list
1 : 1,2,44,5
2 : 4,3,5,2,56,66
Is it possible to check if '44' is in List column in mysql database? I'm using codeigniter and my code looks like:
$this->db->select('*');
$this->db->from("list_table");
$this->db->where("find_in_set('44', 'list')");
$query = $this->db->get();
return $query->result();
I also tried with WHERE_IN but didn't get correct result.
This is what query I get when I enable_profile:
SELECT *
FROM `poslovi`
LEFT JOIN `firme` ON `firme`.`f_id` = `poslovi`.`po_firma_id`
LEFT JOIN `kategorije` ON `kategorije`.`k_id` = `poslovi`.`po_category`
WHERE `po_date_istek` > '2022-03-21 10:37:25'
AND (`po_naziv_oglasa` LIKE '%Radnik u ćevabdžinici%' ESCAPE '!' OR `f_name`
LIKE '%Radnik u ćevabdžinici%' ESCAPE '!')
AND find_in_set("61", po_category) <> 0
AND `po_status` = '1'
ORDER BY `po_date_istek` DESC
LIMIT 10
This is what I have in my database:
Just to mention, if I remove 'find_in_set' I get correct result so the rest of the query is good as I noticed