Your syntax is off. This is off the top of my head as I don't have MySQL to test it against where I am currently. The basic syntax will look kind of like this:
There's no need to do another insert. It's already going to insert.
Code:
DELIMITER | CREATE TRIGGER triggerName BEFORE INSERT ON tableName FOR EACH ROW BEGIN DECLARE num_rows INTEGER; SELECT COUNT(*) INTO num_rows FROM tableName; IF num_rows > 6 THEN DELETE FROM tableName LIMIT 1; END IF; | DELIMITER ;
Comment