mysql怎么获取不重复的数据?

mysql怎么获取不重复的数据?

mysql获取不重复的数据的方法:

在查询语句中添加distinct关键字来过滤重复的记录

select distinct 字段名 from 数据表;

使用方法

  • 对单个字段进行去重sql:

    select distinct  age from user;
  • 对多个字段进行去重sql:

    select distinct name,age from user;
  • 对多个字段进行去重并求count的sql:

    select count(distinct name,age) as total from user;
  • 也可以对select * 进行去重

    select distinct * from user;
©版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容