求助~~Ci的where复杂语句查询
本帖最后由 zsy0228 于 2014-10-27 15:20 编辑表名:aaa
字段:
uid
to_uid
status
求助内容:
查询 uid 或 to_uid 等于2 的 status等于1
请大神帮助俺~~~~~
$this->db->where('(uid=2');
$this->db->or_where('to_uid=2)');
$this->db->where('status', 1);
以前我也遇到过这个问题,后来就是类似这样处理的;
注意字符串里面有() Closer 发表于 2014-10-27 15:23
使用多個 $this->db->where();
他會自動幫你 AND 所有 where 資料
就是说,我想查出uid=2&&status=1 还有to_uid=2&& status=1的所有
上面错了,是这个 查询 uid 和 to_uid 等于2 ,status等于1 是要找 uid = 2, to_uid = 2, status = 1 的資料? 查询 uid 或 to_uid 等于2 ,status等于1 Closer 发表于 2014-10-27 15:20
是要找 uid = 2, to_uid = 2, status = 1 的資料?
是~~~~~~~~~~~~~~~~
Closer 发表于 2014-10-27 15:20
是要找 uid = 2, to_uid = 2, status = 1 的資料?
查询 uid 或者 to_uid 等于2 ,status等于1
使用多個 $this->db->where();
他會自動幫你 AND 所有 where 資料 Closer 发表于 2014-10-27 15:23
使用多個 $this->db->where();
他會自動幫你 AND 所有 where 資料
这个uid 和to_uid是 或者 关系
試試
$this->db->where('uid', 2);
$this->db->or_where('to_uid', 2);
$this->db->like('status', 1, 'none');
页:
[1]
2