用distinct来返回不重复的字段:select distinct Email from user_info;
distinct Email ,name 这样的mysql 会过滤掉Email 和name 两个字段都重复的记录,如果sql这样写:select Email ,distinct name from user,这样mysql会报错,因为distinct必须放在要查询字段的开头。
所以一般distinct用来查询不重复记录的条数。
如果要查询不重复的记录,有时候可以用group by :
select id,name from user group by name;
mysql中去重 distinct 用法
最新推荐文章于 2024-01-26 14:47:33 发布