LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   MySQL Query Help (https://www.linuxquestions.org/questions/programming-9/mysql-query-help-192058/)

Gerardoj 06-10-2004 04:14 PM

MySQL Query Help
 
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.awayscoreMatchData.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'


eric.r.turner 06-10-2004 09:54 PM

Please post your table descriptions, and some data from the tables (perhaps 10 rows of data from each table.) It's difficult to write SQL without knowing that information!


All times are GMT -5. The time now is 06:53 AM.