You have missed FOR EACH ROW
statement
CREATE TRIGGER email_postid_truncate BEFORE INSERT
ON email_postid
FOR EACH ROW
BEGIN
....
Question
I am trying to create new trigger like this. But it gives me an error.
DELIMITER $$
CREATE TRIGGER email_postid_truncate BEFORE INSERT
ON email_postid
BEGIN
SET @cnt = (SELECT count(*) FROM email_postid WHERE status='Remaining');
IF @cnt = 0 THEN
--My query
END IF;
END $$
DELIMITER ;
This trigger gives error like this
Please help.
Solution
You have missed FOR EACH ROW
statement
CREATE TRIGGER email_postid_truncate BEFORE INSERT
ON email_postid
FOR EACH ROW
BEGIN
....