Solved

How would write a query against a MySql db that returns all userName records greater than one record?

Posted on 2014-10-15
2
292 Views
Last Modified: 2014-10-15
How would write a query against a MySql db that returns all userName records greater than one record?  I'm looking for duplicate records in the table.

I'm looking for any duplicated usernames in the table not just a single.

Thanks!

SELECT * FROM  members WHERE UserName  count < 1
0
Comment
Question by:bmanmike39
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
PortletPaul earned 500 total points
ID: 40383425
OK, looking for "duplicates" will depend on what you consider to be a duplicate :)

But one very common technique is to use GROUP BY, HAVING and COUNT() like this:

select
    member_name
from members
GROUP BY
    member_name
HAVING
   COUNT(*) > 1
;

So, for the fields you want to check as a unique record (in bold) list those in BOTH the select and group by clauses
This is important! both must be the same.
0
 

Author Closing Comment

by:bmanmike39
ID: 40383520
Excellent !  worked thanks
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question