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

[讨论/交流] CI中where_in加括号怎么弄

[复制链接]
发表于 2016-3-14 17:25:31 | 显示全部楼层 |阅读模式
我想写个类似 select * from texts where name=1 and (sex in (1,2) or age in (2,3))
应该怎么弄
发表于 2016-3-15 10:23:30 | 显示全部楼层
$this->db->query(select * from texts where name=1 and (sex in (1,2) or age in (2,3)))
发表于 2016-3-16 17:07:12 | 显示全部楼层
$this->db->select('*')->where('name', 1)->where((sex in (1,2) or age in (2,3)))->get('texts')->result_array();

单独的where_in是可以用where_in('sex', array(1, 2))但你的where_in里面有两个条件的,好像不能直接使用,只能手动拼接

本版积分规则