I have 2 tables on my DB, called
PredictionData and
MatchData, the first one is where all the predictions of the user are stored, the second table is where the real scores are stored. I have the following formula and I would like some help to create the SELECT on base that formula:
Formula:
The user predict:
ITA = 3 ESP = 2
The real scores:
ITA = 4 ESP = 2
If the user predict that ITALY wins and ITALY win then count that one. Or if the user predict that SPAIN wins and SPAIN win then just count that one.
I was creating a select like the below but it weird... It will be great if someone can help here. Thanks
PHP Code:
SELECT Count(*) FROM PredictionData LEFT JOIN MatchData ON PredictionData.matchdate = MatchData.matchdate WHERE PredictionData.homescore > MatchData.homescore AND PredictionData.awayscore> MatchData.awayscore AND PredictionData.homescore > PredictionData.awayscore and PredictionData.homescore <> PredictionData.awayscore and PredictionData.homescore <> MatchData.homescore and PredictionData.awayscore <> MatchData.awayscore and MatchData.homescore <> '0' and MatchData.awayscore <> '0' and PredictionData.User = 'Michael';