Jump to content

Compare 2 values at the same row


aliento

Recommended Posts

Hi i have a site (for personal use) which i see the soccer games stats.

I have done a lot comparιson between the goals scores a team and the goals accepts at the last 6 games.

I compare those goals and i see the best attacks and the best defences.

Now i stuck as i want to see the games with best attacks and the worst defence.

I have all the games haven't started at the table 'games', within i have :

 

table : games

--------------------------------------------------------------------------------------------------

| id | game_id | home_attack | home_defence | away_attack | away_defence |

--------------------------------------------------------------------------------------------------

home_attack : goals achieved the home team in last 6 games

home_defence : goals accepted the home team in last 6 games.

The same for the away team.

 

I want to find out from the db the best 30 matches with the best home_attack and the worst away_defence .

 

The mysql can do this action ?

 

I tried to add another field with a calculation which was : home_attack + away_defence but it didn't work.

 

The site is in Greek is here balllab.net

Link to comment
Share on other sites

Well, to start, the database is not set up correctly and you are making it harder than it needs to be.

 

 

 

home_attack : goals achieved the home team in last 6 games

home_defence : goals accepted the home team in last 6 games.

 

You should not store 'calculated' data such as this. Instead, you create your queries to calculate the data dynamically. In fact, your explanation doesn't make sense to me. If the table is 'games' wouldn't you store the data for each individual game in that table?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.