用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3770|回复: 4
收起左侧

如何查找数据库中某字段不为空的记录

[复制链接]
发表于 2011-5-29 23:51:56 | 显示全部楼层 |阅读模式
有字段CN,如何查找字段CN不为空的记录?
 楼主| 发表于 2011-5-29 23:59:31 | 显示全部楼层
if($fl){
                if ($fl=="cn")                $this->db->where('cn !=', 'NULL');
                if ($fl=="hk")                $this->db->where('hk !=', 'NULL');
                }
 楼主| 发表于 2011-5-29 23:59:47 | 显示全部楼层
if($fl){
                if ($fl=="cn")                $this->db->where('cn !=', '');
                if ($fl=="hk")                $this->db->where('hk !=', '');
                }
发表于 2011-5-30 12:33:30 | 显示全部楼层
本帖最后由 zhouli520 于 2011-5-30 12:33 编辑

where cn is not null
发表于 2011-5-31 08:47:59 | 显示全部楼层
$this->db->where('length(trim(cn)) !=', "''", false);

本版积分规则