| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Dec 2007
Posts: 241
![]() ![]() ![]() | Need to delete duplicate entries in mysql I have a database of over 600,000 business listings, and there are probably 100,000 duplicates in there. So, I'm asking how to delete the duplicates efficiently. I made a table with all of the listing names that have duplicates. I need to somehow check all the names against the 600,000 listings and delete the duplicates. The duplicate listings have all the same information, just a different ID in the table. Any help is appreciated, Thanks, Dave |
| | |
| | #2 (permalink) |
| Domains my Dominion Join Date: Aug 2005 Location: Web 1.0
Posts: 9,963
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | You could use SELECT DISTINCT (without the ID field) so you won't get dupes then INSERT the recordset into a fresh table, same structure as original table, the ID will be autogenerated.
__________________ NameNewsletter.com - free lists of available domain names ZoneFiles.net (beta) - ccTLD and gTLD droplists |
| | |
| | #3 (permalink) |
| Senior Member ![]() Join Date: Apr 2006
Posts: 1,478
![]() ![]() ![]() ![]() ![]() ![]() ![]() | If this query works SELECT * FROM table1,table1 as vtable WHERE vtable.id > table1.id AND vtable.fieldname = table1.fieldname then this should remove the duplicates DELETE FROM table1 USING table1,table1 AS vtable WHERE vtable.id > table1.id AND table1.fieldname = vtable.fieldname re: Mysql remove duplicate data or rows with DISTINCT
__________________ Free Keyword Popularity, CPC, etc... Namejet, Snapnames, GoDaddy Lists Offers valid for 24 hours. Now Available: Rented.com |
| | |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |