丶大熊 发表于 2016-3-14 17:25:31

CI中where_in加括号怎么弄

我想写个类似 select * from texts where name=1 and (sex in (1,2) or age in (2,3))
应该怎么弄

Aloghli 发表于 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)))

Michael锐生 发表于 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里面有两个条件的,好像不能直接使用,只能手动拼接
页: [1]
查看完整版本: CI中where_in加括号怎么弄