thinkphp 去重查询
2023-03-29 23:03:03
150
{{single.collect_count}}
$test_data = M('hot');//实例化数据表$data = $test_data->Distinct(true)->field('descriprion')->order('description desc')->select();//利用distinct方法去重$data = $test_data->group('description')->order('description desc')->select();//利用group方法去重dump($data);

对于两种去重方式: 
利用distinct去重、简单易用,但只能对于单一字段去重,并且最终的结果也仅为去重的字段,实际应用价值不是特别大。 
利用group去重,最终的显示结果为所有字段,且对单一字段进行了去重操作,效果不错,但最终显示结果除去去重字段外,按照第一个字段进行排序,可能还需要处理。

转载于:https://www.cnblogs.com/zc290987034/p/11156989.html

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}