lindao310 发表于 2008-7-29 22:25:50

数据库操作 where 条件问题

表里一个字段是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 编辑 ]

Hex 发表于 2008-7-30 00:11:22

$this->db->where('score >',60);
$this->db->where('score <',80);
这相当于 where score>60 and score<80 为什么不行?你还有其他条件吧?

jgcao 发表于 2008-7-30 15:40:21

试试
$this->db->where('score > 60');
$this->db->where('score < 80');

实在不行写sql语句,用$this->db->query() 执行

lindao310 发表于 2008-7-30 17:18:33

问题解决了

是还有其他的条件,我把他们顺序换一下取出来的结果就对了。
谢谢上面两位的回答。

oraclelee 发表于 2011-12-29 09:39:50

mark标记 以后有用处。

thenbsp 发表于 2011-12-30 16:28:20

用query嘛
页: [1]
查看完整版本: 数据库操作 where 条件问题