I'm trying to create a simple chat system using database but I want it to automatically automatically truncate when it reaches a rows limit in the database.
The trigger code I made was this:
BEGIN
SELECT COUNT(*) INTO @a FROM sandbox_webchat;
IF @a >= 120 THEN
TRUNCATE sandbox_webchat;
END IF
END
But he accuses the IF and the END IF as a syntax error, even tested it with the parentheses, but he still accuses the error.
IF (@a >= 120) THEN ... END IF
One or more errors have occurred while processing your request: The following query has failed: "CREATE TRIGGER
QuandoAtingirLimite
BEFORE INSERT ONsandbox_webchat
FOR EACH ROW BEGIN SELECT COUNT (*) INTO @a FROM sandbox_webchat; IF @a> = 120 THEN TRUNCATE sandbox_webchat; END IF END" p>MySQL said: # 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 'END' at line 6