mysql-codeigniter在find_in_set中添加IS NULL
作者:互联网
通过codeigniter框架生成查询时
$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();
我在查询中自动添加IS NULL时出错
它产生
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
代替
SELECT `id`, `memo`, `sent_to`, `sent_by`, `read_by`, `date` FROM `memos`
WHERE FIND_IN_SET('1',`sent_to`) ORDER BY `id` DESC
解决方法:
您需要添加!= 0是您的where子句以删除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();
标签:codeigniter-3,mysql,codeigniter 来源: https://codeday.me/bug/20191012/1897888.html