Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eliminating duplicate records

Status
Not open for further replies.

MarcDePoe

Programmer
Dec 19, 2000
101
0
0
US
I'm using the LOAD DATA command to import a csv file.
I realize that on an indexed field, I have the option of either IGNORE or REPLACE on the load, but I need to be able to produce a list of which records (emails in this case) were duplicates.
We are in the process of converting to MySql from Access, and since MySql does not support nested select statements, the following code no longer works...

SELECT * FROM TABLE A
WHERE A.id <> 1
AND A.id <> (SELECT max(id) from TABLE)
AND id > (SELECT min(id) from TABLE B Where A.email = B.email AND B.id <> 1 AND B.id <> (SELECT max(id) from TABLE))

Anyone have a clue how I can do this efficiently???
 
Or is there a way I can select all duplicate records from a table with MySql? (some kind of opposite distinct trick or something :))

I'm absolutely lost.

Any help would be greatly appreciated.
 
Try using a self-join to query the table directly.
DevShed.com have a MySQL section on self joins that is quite helpful for this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top