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

[数据库] CI ar distinct 的正确用法

[复制链接]
发表于 2010-7-19 14:35:47 | 显示全部楼层 |阅读模式
刚才使用ar查询数据库发现distinct根本不起作用
$this->db->distinct('citycode');
$this->db->from('area');
$this->db->get();
结果 SELECT DISTINCT * FROM (`area`);这毫无意义,试了n种方法不行,查看源码发现distinct不支持字段名作为参数.
正确的用法是用$this->db->select('citycode');确定字段名
$this->db->select('citycode');
$this->db->distinct();
$this->db->from('area');
$this->db->get();

评分

参与人数 1威望 +5 收起 理由
Hex + 5 我很赞同

查看全部评分

发表于 2013-2-12 18:03:39 | 显示全部楼层
感谢分享。。。我终于找到用法了。。。呵呵。

本版积分规则