Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old October 3rd, 2000, 05:04 PM
scream scream is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 441 scream User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 59 m 38 sec
Reputation Power: 9
Send a message via ICQ to scream
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).]

Reply With Quote
  #2  
Old October 3rd, 2000, 06:32 PM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 9
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.

Reply With Quote
  #3  
Old October 4th, 2000, 10:56 PM
billyo billyo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 114 billyo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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.

Reply With Quote
  #4  
Old October 10th, 2000, 09:24 PM
scream scream is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 441 scream User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 59 m 38 sec
Reputation Power: 9
Send a message via ICQ to scream
Thanks for the input. Your suggestions allowed me to accomplish what I was hoping for!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > delete duplicate entries from mysql


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway