Solved

Updating a league table(Soccer) in ASP/SQL

Posted on 2004-05-02
4
1,342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

630 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