codeigniter adding the IS NULL in the find_in_set

随声附和 提交于 2019-12-02 00:02:10

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();

Below code 100% work. try it,

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

Use this

$query = $this->db->query("SELECT * FROM memos WHERE FIND_IN_SET('1',sent_to) ORDER BY id DESC");
$result = $query->result_array();
return $result;

result_array(); this for return data as objective array

thucnq1994

You simply need to write a mysql query for string variable and run it by using $this->db->query(''); instead of using active record.

P/s: Sorry for my bad english.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!