Updating a league table(Soccer) in ASP/SQL

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
Gonzo84Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
ldbkuttyCommented:
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
 
Gonzo84Author Commented:
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
 
Gonzo84Author Commented:
sorry about the spelling mistakes, i was rushing to get everything out of my head onto this screen!
0
 
Pietro_PCommented:
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

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.