vendredi 29 octobre 2021

IF Sentance in MySQL trigger

I am building an automatic ranking on a game server and i have to do this by manipulating the MySQL database, this is not a strong knowledge area for me so ive tried to be a bit hacky with this. i need to use the trigger function of SQL db.

CREATE TRIGGER `ranking_up` AFTER UPDATE ON `highscore` FOR EACH ROW

BEGIN

IF NEW.score >= '10' and <= '100' THEN
    UPDATE department_members
    SET rankID=1 WHERE userID = NEW.userID;
END IF;
IF NEW.score >= '100' and <= '300' THEN
    UPDATE department_members
    SET rankID=2 WHERE userID = NEW.userID;
END IF;
IF NEW.score >= '300' THEN
    UPDATE department_members
    SET rankID=3 WHERE userID = NEW.userID;
END IF;
END

I get the standard MySQL #1064 and i have tried to talk to my rubber duck... does not work it makes perfect sense for me but apparently does not work.

I am looking for the answer ofc BUT i also want to learn on my mistake here, what am i doing wrong ?

Aucun commentaire:

Enregistrer un commentaire