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

数据库操作 where 条件问题

[复制链接]
发表于 2008-7-29 22:25:50 | 显示全部楼层 |阅读模式
表里一个字段是int型,名字叫score。我要查询的结果是  这个score 在两个数字之间的结果,比如60到80之间。
我是这样写的。
$this->db->where('score >',60);
$this->db->where('score <',80);
或者是这样
$this->db->where('score >',60);
$this->db->orwhere('score <',80);
都不行。我想用$this->db->where_in(),可是手册上说的好像在这中情况下没法用。
谁能告诉我怎么写才对啊? 非常感谢!

[ 本帖最后由 lindao310 于 2008-7-29 22:27 编辑 ]
发表于 2008-7-30 00:11:22 | 显示全部楼层
$this->db->where('score >',60);
$this->db->where('score <',80);
这相当于 where score>60 and score<80 为什么不行?你还有其他条件吧?
发表于 2008-7-30 15:40:21 | 显示全部楼层
试试
$this->db->where('score > 60');
$this->db->where('score < 80');

实在不行写sql语句,用$this->db->query() 执行
 楼主| 发表于 2008-7-30 17:18:33 | 显示全部楼层

问题解决了

是还有其他的条件,我把他们顺序换一下取出来的结果就对了。
谢谢上面两位的回答。
发表于 2011-12-29 09:39:50 | 显示全部楼层
mark标记 以后有用处。
发表于 2011-12-30 16:28:20 | 显示全部楼层
用query嘛

本版积分规则