Solved

Updating a league table(Soccer) in ASP/SQL

Posted on 2004-05-02
4
1,322 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 130 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Loading csv or delimited data files to MySQL database is a very common task frequently questioned about and almost every time LOAD DATA INFILE comes to the rescue. Here we will try to understand some of the very common scenarios for loading data …
This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now