Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

SQL query problem: how tp select all duplication in the table?

 
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a table with the following columns:

1. contact_id
2. fname
3. lname
4. email

The email column must be unique (unfortunately it's not); therefore, I have to delete all duplication in the system.

Question: how can I select all duplication in the table?

I tried this...didn't work (I'm expecting only the emails that are duplicated)

THANK YOU!


 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something like this? That works with MySQL not sure for other DBMS.
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if this works for your DBMS and with JDBC, but in Oracle I would write something like this:



or fully compatible with your example



Can try this in your environment? Maybe you have to make some modifications to the syntax.

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Thank you John,

this one was what I was looking for!
 
    Bookmark Topic Watch Topic
  • New Topic