|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to Delete Duplicate Records?
In a MySQL (3.22.51) file I have three fields
idx (Auto Increment) filename pathname I use an insert command in a dump.sql file to add new records to my file. INSERT INTO jpeglist (idx, filename, pathname) VALUES ( '', 'c-purpsparkle26w-1.jpg', 'dennisj/20021007'); Sometimes I end up adding the same record twice. How can I find all duplicate records in Field 'filename' and delete the extra records? Can I change the INSERT INTO command so new records are added and duplicate records are only updated? TIA Dennis |
|
#2
|
|||
|
|||
|
Maybe you'll find this interesting?
http://www.mysql.com/doc/en/REPLACE.html
__________________
Best Regards, Håvard Lindset |
|
#3
|
|||
|
|||
|
SELECT *, count(*) cnt FROM tableName GROUP BY fieldname1, fieldname2, .... HAVING cnt > 1
This will return all the records in the tableName more than 1 time. Include all the fields except the auto increment field in GROUP BY part. Rest is trivial |
|
#4
|
|||
|
|||
|
Why not use a unique index on the table?
That way when it comes to actually inserting the record: "INSERT INTO jpeglist (idx, filename, pathname) VALUES ( '', 'c-purpsparkle26w-1.jpg', 'dennisj/20021007');" it will complain about this being a duplicate record and will not insert a new record. This will elliminate duplicate files without actually having to build any code for it? Thanx Clive |
|
#5
|
|||
|
|||
|
Every man has different problems vith files. I know how to solve the problem with duplicate files. I use Duplicate checker PRO 6.0 for such purposes (http://www.atory.com/Dupe_Checker_PRO/). I suggest you to try it if you experience "dupe-problem"...
Good luck! |
|
#6
|
|||
|
|||
|
You've exhumed a long-dead thread to pimp an irrelevant product (the problem is duplicate records in a database, not duplicate files).
Please don't do that.
__________________
"A pawn is the most important piece on the chessboard -- to a pawn" |
|
#7
|
|||
|
|||
|
Find and delete duplicate files and folders by Dupe Checker PRO
![]() |
|
#8
|
||||
|
||||
|
Deja vu.
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter! DevArticles Forum Moderator "The net is a waste of time, and that's exactly what's right about it." -- William Gibson |
![]() |
| Viewing: Dev Articles Community Forums > Databases > General SQL Development > How to Delete Duplicate Records? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|