Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 mySQL: Find all duplicates in a column Jump to:  
Category: >> mySQL >> Find all duplicates in a column Bookmark and Share

<< lastnext >>

Snippet Name: Find all duplicates in a column

Description: Easy ways to find all duplicates in a database column(s)n.

Comment: (none)

Language: MYSQL
Highlight Mode: MYSQL
Last Modified: March 01st, 2009

-- Depending on your SQL syntax, this might work:
 
SELECT COUNT(*), colname FROM TABLE 
GROUP BY colname HAVING COUNT(*) > 1
 
-- or similarly,
 
SELECT FIELD, COUNT(FIELD) AS NumOccurrences 
FROM TABLE GROUP BY FIELD HAVING ( COUNT(FIELD) > 1 )
 
-- or if trying to find a duplicate combination 
-- of multiple columns,
 
SELECT column1, column2, column3, COUNT(column3) 
FROM TABLE GROUP BY column1, column2, column3 
HAVING COUNT(column3) > 1


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 76 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?