Yesterday, a member of stackoverflow helped me change a table in my database with a case from another table. But I need to input one more condition, and don't know where to put it. I have theese two tables:
liga
uid | name | games | points |
___________________________________
1 | Daniel | 0 | 0 |
2 | Mikkel | 0 | 0 |
and kamp2:
uid | k1 | k1r | k2 | k2r | week |
__________________________________________________
1 | 1 | 2-1 | X | 2-2 | 14 |
2 | 2 | 1-1 | 1 | 2-1 | 14 |
To those who haven't got it yet, it's a betting-game, where the user bets on 2 matches (k1 and k2) and a result on both (k1r and k2r). Let's say the first match is 2-1, i use:
UPDATE liga l JOIN
kamp2 k
ON l.uid = k.uid
SET point = (CASE WHEN k.k1 = '1' and k.k1r = '2-1' THEN point + 5
WHEN k.k1r = '2-1' AND k.k1 <> '1' THEN point + 3
WHEN k.k1 = '1' AND k.k1r <> '2-1' THEN point + 1
ELSE point
END)
WHERE l.uid = k.uid ;
and it workes perfectly. Daniel gets 5 points and Mikkel gets 3 points. But now to my problem. Next week they will send in another bet with the week-number 15. So I actually just want it to
UPDATE liga l JOIN
kamp2 WHERE k.week = 15
......
but it won't allow that. Where should I put the condition then?