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

[已解决] 谁知道用ci怎么写关于between and的sql语句?

[复制链接]
发表于 2010-3-30 15:03:10 | 显示全部楼层 |阅读模式
:)
大家好~ 请问谁知道ci里的between and 是怎么写的~就像就平均的话是select_avg(),那bentween and 的写法是什么?
例如 select prod_name,prod_price from products where prod_price between 5 and 10;
请各位高手指教~
发表于 2010-3-30 15:23:57 | 显示全部楼层
额,你就直接写sql语句就好了呀,写完了,用$this->db->query($sql)
或者用$this->db->where('prod_price between 5 and 10');
 楼主| 发表于 2010-3-30 15:38:48 | 显示全部楼层
回复 2# ywqbestever


    恩~ 谢谢你啊~ 不过betwenn and 有没有类似select_num()的做法啊~
发表于 2010-3-30 20:37:11 | 显示全部楼层
没有
发表于 2010-3-30 20:40:30 | 显示全部楼层
没有吧,这里面没有,就应该没有的。
system/database/DB_active_rec.php
 楼主| 发表于 2010-3-31 09:31:42 | 显示全部楼层
回复 4# visvoy

哦~谢谢你啊~
 楼主| 发表于 2010-3-31 09:32:48 | 显示全部楼层
回复 5# uroko


    恩 ~ 我在网上找了很做资料也没有~呵呵 看来真的没有了~
 楼主| 发表于 2010-4-13 17:59:41 | 显示全部楼层
select prod_name,prod_price from products where prod_price between 5 and 1;
$this->db->select('prod_name,prod_price');
$this->db->where('prod_price between 5 and 1');
$this->db->get('products');
目前也只能用这个方法了~
发表于 2011-12-26 13:18:55 | 显示全部楼层
ci小新 发表于 2010-4-13 17:59
select prod_name,prod_price from products where prod_price between 5 and 1;
$this->db->select('prod_ ...

谢谢了。正需要。
发表于 2017-7-19 16:16:45 | 显示全部楼层
本帖最后由 寄语残云 于 2017-7-19 16:20 编辑

$this->db->select('prod_name, prod_price')->where(['prod_price >'=>5, 'prod_price <'=>10])->get('products')->result_array();
CI框架的连贯操作,请参考

本版积分规则