![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Dec 2001
Posts: 7,952
|
Php / Mysql help needed...
Anyone have code or know how to delete duplicate rows in a larger database. I have about 55k rows and want to remove all the duplicate urls in it.
Thanks |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Mar 2002
Location: Living in the bottle.
Posts: 590
|
/
dev nul
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
So Fucking Banned
Join Date: Jan 2005
Location: At My Desk
Posts: 2,904
|
delete
backup first
if you know what your deleting "hair in my cabbage" is all the data in that field for example delete from <table> where <tableelement> LIKE 'hair in my cabbage' backup first!!!!!!!!! dont blame me later |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
Confirmed User
Industry Role:
Join Date: Jan 2004
Location: Nor'easterland
Posts: 1,914
|
Quote:
Alternately, a cute way to do a de-facto culling is to ALTER TABLE and make your url column UNIQUE, ignoring (and therefore dropping) duplicates: ALTER IGNORE TABLE sometable ADD UNIQUE (url) ... which would serve the additional purpose of permanently removing the possibility of duplicate URLs in the future, as well. Obviously you'll want to back up everything before you try any of this. ![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Join Date: Aug 2003
Posts: 1,798
|
I'd do something like this (but backup first)
$rs = mysql_query("SELECT id, url FROM your_table ORDER BY id ASC"); while (list($id,$url)=mysql_fetch_row($rs)) { mysql_query("DELETE FROM your_table WHERE url = '$url' AND id != '$id'"); } that will go through all your rows and delete all duplicates other than the first one ... you could change ASC to DESC to make it delete all but the newest ... obviously you have to probably change the field and table names though.
__________________
TGP Webmasters: sign up for the top 100 tgp list! Submit galleries If you add me to icq (title) make sure to mention GFY or I'll think you're a bot and deny you. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 | |
Confirmed User
Industry Role:
Join Date: Dec 2001
Posts: 7,952
|
Quote:
thank you! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 | |
Confirmed User
Industry Role:
Join Date: Jan 2004
Location: Nor'easterland
Posts: 1,914
|
Quote:
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |