Leburn Posted September 19, 2006 Share Posted September 19, 2006 Hey guys,I have a minor problem here. I run a Hockey website where I use a script to parse the stats into the DB. Unfortunately, the Forward and Goaltender stats are stuck together. What I do currently is use 2 tables: 1 for Forwards and the other for Goaltenders, that's not the problem. My problem is my script parses the Forwards into the Goaltender table and vice versa. To combat this I have my script rename the position category to 'A'. By doing this, it allows me to use phpAdmin to use the search to find all entries with position 'A' and then delete the entries accordingly. I then remove duplicate entries afterwards based on the playername category.[hr]Anyways my question is how can I create a script that uses a mysql query to do the following:1. search table players for 'A' in category 'pos'2. delete all entries (rows) that have 'A' in category 'pos'3. delete duplicate entries based on category 'playername'If someone can make me this script, I can then duplicate it for the goalie table myself. Link to comment https://forums.phpfreaks.com/topic/21300-how-to-delete-db-entries-based-on-like-clauses/ Share on other sites More sharing options...
fenway Posted September 20, 2006 Share Posted September 20, 2006 1 & 2 -- DELETE * FROM yourTable WHERE pos ='A'3 -- Not that I'm sure why you're getting duplicates, but you can use a unique index to prevent these records from being added in the first place. Link to comment https://forums.phpfreaks.com/topic/21300-how-to-delete-db-entries-based-on-like-clauses/#findComment-95181 Share on other sites More sharing options...
Leburn Posted September 21, 2006 Author Share Posted September 21, 2006 Well first I should tell you what my site is about.It is a Fantasy based Hockey League using real players and teams (although we have contracted/added real teams). We use a text-based simulator called FHL Sim (Fantasy Hockey League Simulator) available @ www.fhlsim.com.This sim is basically takes the life of a GM were you trade, draft, sign, release players. Your ultimate goal is obviously to win the Cup. Basically consider it the manager part of the EA Sports NHL series, but with 30 real GMs.One of the nice features is the simulator outputs the statistics to html pages.Now what I do is use a script to parse the data from these pages and place them into a DB. The script looks through the html source code to find the various stats. I personally did not make the script from scratch, I was fortunate enough to have someone else send me a sample, which I then worked on for my league.[hr]Now I think one of the duplicate issues is the fact that some players play for more than one team and therefore have 2 or more entries. The only issue here is for the current season stats, were all I care about is the latest entry for each player. However, I believe this issue will be resolved in our upcoming season as we will be doing the transactions differently.Anyways, if you want to check out some examples of what I am talking about feel free to reply here, and I can post a few links to the stat pages, my parsing script, etc. Link to comment https://forums.phpfreaks.com/topic/21300-how-to-delete-db-entries-based-on-like-clauses/#findComment-95952 Share on other sites More sharing options...
fenway Posted September 21, 2006 Share Posted September 21, 2006 That doesn't change anything -- you'll have to decide which of the duplicates you want to keep. Link to comment https://forums.phpfreaks.com/topic/21300-how-to-delete-db-entries-based-on-like-clauses/#findComment-96064 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.