im using
CREATE FUNCTION UPDATEGames(usernameIN CHAR(15) ,opponientIN CHAR(15) ,mFilePath TINYTEXT,oFilePath TINYTEXT)
BEGIN
UPDATE games
IF (username = opponientIN AND FilePath = oFilePath) THEN SET opLastTurn = NOW(),Turn=Turn+1
ELSEIF (username = usernameIN AND FilePath = mFilePath) THEN SET myLastTurn = NOW(),Turn=Turn+1
END IF
END;
but it didnt worked, what am i ding wrong?and if it isnt possible to do it so then how can i simulate this logic?
UPDATE games set opLastTurn = NOW(),Turn=Turn+1 where username = opponientIN AND FilePath = oFilePath(and a 2nd update forusernameIN), without the if-thingy. Have an index on username, filepath. Also, a function needs to return something, so maybe use a procedure.