Home > Database > Mysql Tutorial > mysql 查找表中某个字段的重复次数

mysql 查找表中某个字段的重复次数

WBOY
Release: 2016-06-01 09:57:06
Original
1159 people have browsed it

比如有一张表user_table, 里面有一个字段user_name,我们需要查找user_table表里面有多少个重复的user_name以及出现的次数。这时候,我们可以使用下面的SQL语句来获取:

<code class="language-sql">select user_name,count(*) as count from user_table group by user_name having count>1; </code>
Copy after login

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template