|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
I have a MySQL table that looks something like this:
id url name 1 http://www.yahoo.com Yahoo 2 http://www.aol.com AOL 3 http://www.excite.com Excite 4 http://www.yahoo.com YAHOO! 5 http://www.yahoo.com/abc Yahoo! Can someone give me the Perl code that could go through the MySQL table and remove entries with duplicate URLs? No consideration should be given to name. For this example 1 and 4 should be considered duplicates. 4 should be removed and 1 should stay. 6 should not be regarded as a duplicate. I appreciate the help! Ryan McKillen [This message has been edited by scream (edited October 03, 2000).] |
|
#2
|
|||
|
|||
|
Well you should have made the field unique in the 1st place. The easiest way (if it works) to fix it is to alter the table and make the field a unique key.
If that doesn't work you'll have to do some working with arrays/hashs and get it fixed. |
|
#3
|
|||
|
|||
|
what would happen if you used a query to create a new table with just distinct entries?
mysql>CREATE distinct_urls SELECT id, url, name ->FROM your_table ->GROUP BY url; That query would create a new table with just the distinct URL's, an id from one of them, an a name from one of them. I don't know if you could control whether or not 1 became 4, or 4 became 1. At any rate, it's worth a try. |
|
#4
|
|||
|
|||
|
Thanks for the input. Your suggestions allowed me to accomplish what I was hoping for!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > delete duplicate entries from mysql |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|