本文操作环境:windows10系统、thinkphp5版、dell g3电脑。
thinkphp中distinct的用法是什么tp中distinct()的用处主要是去除重复的值
distinct 方法用于返回唯一不同的值 。
$model->distinct(true)->field('name')->select();
生成的sql语句是:
select distinct name from think_user
示例如下:
显示的是这样的
在加入distinct的话:
显示结果为
下面为贴出来的代码
$offernum = m('offer')->distinct(true)->where('order_id='.$order_id)->field('user_id,number')->select();dump($offernum);
推荐学习:《php视频教程》
以上就是thinkphp中distinct的用法是什么的详细内容。
