Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Updating a league table(Soccer) in ASP/SQL

Posted on 2004-05-02
4
Medium Priority
?
1,350 Views
Last Modified: 2007-12-19
Hi There.

I am having a pretty large problem here.

I am doing a project for my HND for a football league and i am at the point where so far everything is goin good but i need to update the League table. For those that dont know how a league table works here it is:

For a Win you get 3 points
A loss u get 0
a Draw u get 1

Any goals u score go into you 'Goals for'
And any scored against you go in your 'Goals against".

Basically i already have some ASP files where the administrator of the system types in the results for games played now i need to update this league table depending on the results.  I want to execute something like this:

If HomeScore is greater than AwayScore Then Add 1 to the played field, add 1 to the Wins field, add 3 to the Points field and for the goals for and against i thought it may look something like this:

For = for + "HomeScore'
Against = Against + "AwayScore"

I have absolutely no idea how to do this, i dont know whether to use an Insert statement or an update Statement.

Any Help will be greatly appreciated because frankly i am Stumped!!!!!

thanks for taking the time to read this
0
Comment
Question by:Gonzo84
  • 2
4 Comments
 
LVL 32

Expert Comment

by:ldbkutty
ID: 10974250
I am not sure whether i understood you correctly...but a general query would be like this:-

UPDATE yourtable SET played_field=played_field+1, wins_field=wins_field+1, points=points+3, goals_for=goals_for+5, goals_against=goals_against+4 WHERE homescore>awayscore;

I assumed goals_for = 5 and goals_against = 4....

but surely you have to tell us the table structure(that is, how many tables you have used and which fields belong to which tables) so that we can help you exactly.

Best Regards.
0
 

Author Comment

by:Gonzo84
ID: 10976074
Thanks for the reply, sorry about the vague explanation.

Basically, i have a table called

TEMPResults and a table called
weeklyfixtures.  Once a week the administrator of the league will Update game results pulled from the weeklyfixtures and INSERT them into TEMPresults.  

I wanted to run the Sql statement from the results entered into the TEMPresults table to update a table called LeagueTable

The TEMPresults table has the following fields:

Id, HomeTeam, HomeScore, AwayTeam, AwayScore

The actualy values in this table are the results of the games played.

The LeagueTable table has the following fields:

Team, P, W, L, D, F, A, Pnts

The only data in this table is the names of the teams and a load of Zero's.

The thing that is i will need the league table to be updated depending on the team, so

somewhere along the lines i think i will need a piece of either an IF statement or the SQL statement to look like this

If HomeScore>AwayScore...
...WHERE Team(Field in Leaguetable) = HomeTeam(Field in TEMPresults table)

I think i have coverted quite abit but there is alot to cover, let me know if you need to be elaborate on anything
0
 

Author Comment

by:Gonzo84
ID: 10976810
sorry about the spelling mistakes, i was rushing to get everything out of my head onto this screen!
0
 

Accepted Solution

by:
Pietro_P earned 520 total points
ID: 10982886
I have had a problem like this myself.  What i did was firstly forgot about the complex IF and SQL statements.

All you need to do is Run a few SQL statements to update the results entered into Othertable names

HomeWin
HomeLoss
Draws
AwayWin
AwayLoss

What you need to do is write an SQL statement that INSERTS all of the Home Teams that won into the HomeWin table etc.

I.e

Sql1 = "INSERT INTO HomeWins (Team, Played, Wins, Loses, Draws, For, Against, Points) Values ('" & HomeT(x) & "', 1, 1, 0, 0, " & Homescore(x) & ", " & AwayScore(x) & ", 3)"

As you can see there are some values that are simply number and others that will be pulled from the outcome of the last ASP file, the one that you use to pull data from a table and Update into another one.

Basically fiddle around with the ASP So that after all of the games have been proberly inserted into the correct table They are all INSERTED into one table which you will then later on use and ADD (I REPEAT ADD, NOT REPLACE) the values in this table to the Actual League Table.

Bing Bang Boom, Hey Presto, you have updated a league table!

Good Luck let me know what the outcome is and if i need to explain in greater details.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month12 days, 6 hours left to enroll

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question