This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one 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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL query problem: how tp select all duplication in the table?