I have these 2 triggers, but both give a syntax error at "THEN", and I cant figure out why. All tables are as they're called and so on, and I start it in delimiter:
CREATE TRIGGER capacity
AFTER INSERT ON Participants
FOR EACH ROW
BEGIN
IF (NEW.status = 'a' AND
(SELECT capacity FROM rooms WHERE room = NEW.PID) > (SELECT COUNT(*) FROM Participants WHERE meetID = NEW.meetID) THEN DELETE FROM Participants WHERE PID = NEW.PID AND meetID = NEW.meetID;
END IF;
END $$
CREATE TRIGGER iraLikesBeer
AFTER INSERT ON Meetings
FOR EACH ROW
BEGIN
IF ( NEW.what LIKE '%beer%' AND 'ira' NOT IN(SELECT pid FROM Participants WHERE meetid = 'NEW.meetid') THEN
INSERT INTO Participants
VALUES (NEW.meetID,'ira', 'u');
END IF;
END $$
Both of your trigger definitions have imbalanced parentheses.
IF (NEW.status = 'a' AND (SELECT ...) > (SELECT ...) THEN ...
^
The first opening paren does not have a close paren.
The same problem exists in your second trigger.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.