Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Peter Primrose
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!


 
denis sorn
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.
 
John Bengler
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic