phpmysqlcodeignitercodeigniter-3find-in-set

codeigniter adding the IS NULL in the find_in_set


while generating the query through codeigniter framework

$this->db->select('id,memo,sent_to,sent_by,read_by,date')->from('memos')
    ->where("FIND_IN_SET('1',`sent_to`)")->order_by('`id`','DESC')->get();

i got an error of adding IS NULL in the query automatically

it produce

SELECT `id`, `memo`, `sent_to`, `sent_by`, `read_by`, `date` FROM `memos` 
WHERE FIND_IN_SET('1',`sent_to`) IS NULL ORDER BY `id` DESC 

instead of

SELECT `id`, `memo`, `sent_to`, `sent_by`, `read_by`, `date` FROM `memos` 
WHERE FIND_IN_SET('1',`sent_to`) ORDER BY `id` DESC

Solution

  • You need to add !=0 is your where clause to remove IS NULL

    $this->db->select('id,memo,sent_to,sent_by,read_by,date')->from('memos')
        ->where("FIND_IN_SET('1',`sent_to`)!=",0)->order_by('`id`','DESC')->get();