This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQL query problem: how tp select all duplication in the table?    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL query problem: how tp select all duplication in the table?    " Watch "SQL query problem: how tp select all duplication in the table?    " New topic
Author

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

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
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

Joined: Apr 30, 2008
Posts: 33
Something like this? That works with MySQL not sure for other DBMS.
John Bengler
Ranch Hand

Joined: Feb 12, 2009
Posts: 133
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

Joined: Sep 10, 2004
Posts: 755


Thank you John,

this one was what I was looking for!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SQL query problem: how tp select all duplication in the table?
 
Similar Threads
JPA many-to-many with extra attribute
Cannot print report please help.
Default SSL context init failed: null
Hibernate Composite keymapping
cloning question