I'm trying to update a column after I join two tables. If one column matches another I want to change another to 'W' and if it is already blank/NULL I want to leave it, otherwise I want to change it to 'L'. Here is what I have:
UPDATE user_games
LEFT JOIN games ON user_games.game_key = games.game_id
SET user_games.result = CASE
WHEN user_games.pick = games.winner then 'W';
WHEN games.winner = NULL then NULL;
ELSE 'L';
END;
I'm getting this error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 4
I'm using Server version: 10.4.20-MariaDB