I have three tables:
Table Results:
- id
- homeScore
- awayScore
Table Ladder:
- id
- points
Table Predictions
- id
- homeScore
- awayScore
I want to add points to all ids in Table Ladder, triggered by insertions, modifications or removals in Table Results, depending on the value of homeScore,awayScore from table Predictions.
And I have rules like:
- If user result and real result are identical, +5 points
- If user predicted correct winner, +2 points
- If user predicted correct goal difference +3 points
- If user predicted correct goals scored, +1 point (can happen for both teams)
Is this possible with only SQL? If not, how do I approach this with PHP?