kazaff 发表于 2009-10-26 08:56:01

恩,明白

lihao812 发表于 2009-10-26 11:49:12

回复 9# visvoy


    貌似版主没仔细看我的标题...:L

visvoy 发表于 2009-10-26 13:25:38

你的用法不对,->distinct($val)其中$val目前类型只是bool,为真值就在编译的时候加上关键字DISTINCT,字符串类型的$val对->distinct()无效

mckee1990 发表于 2013-7-1 20:43:04

visvoy 发表于 2009-10-23 18:50 static/image/common/back.gif
屏蔽重复的列,单单这个用程序控制就要花费很多额外开销,而数据只要一个distinct就解决了

像模糊查询,查 ...

表a:
id   name
1    name1
2    name2
3    name3
表b:
name   other
name2    other1
name2   other2
请问:
$this->distinct()->from('a')->join('b', 'a.name=b.name')->get()->result_array();
获取的值:
idname other
2   name2other1
2   name2   other2

如果我只是想获取唯一的id是不是
$this->select('a.id')->distinct()->from('a')->join('b', 'a.name=b.name')->get()->result_array();


页: 1 [2]
查看完整版本: 最近发现CI的$this->db->distinct(); 貌似没什么意义!