关键词:DISTINCT 

1、比如数据库一组数据查询如下,返回店铺下所有的区域id

MySQL获取指定字段不重复的记录

 

 2、SQL统计返回指定字段 district 不重复的 记录id,SQL如下

SELECT 
     DISTINCT(district ) 
FROM
    `t_life_shop`

查询结果如下

MySQL获取指定字段不重复的记录

 

 3、TP5.1的写法如下

$list = $this->where($where)->distinct(true)->field('district')->select();

 

相关文章:

  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
  • 2021-11-23
  • 2022-12-23
猜你喜欢
  • 2021-06-20
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2021-09-17
  • 2021-06-19
  • 2021-10-16
相关资源
相似解决方案