我试图在 IF 语句中给出两个条件......下面的两个触发器没有显示任何语法错误,但它们也不起作用。
触发器:1:
如果存在则删除触发器forumpostTrigger
;
CREATE DEFINER = `livecomm`@`localhost` TRIGGER `forumpostTrigger` AFTER INSERT ON `forum_post`
FOR EACH
ROW BEGIN if( (
SELECT count( * )
FROM forum_post
WHERE uid = new.uid
AND parent_id IS NOT NULL
AND is_answer_accepted ) >=30
)
THEN if( (
SELECT sum( vote_count )
FROM forum_post
WHERE uid = new.uid
AND parent_id IS NOT NULL
AND is_answer_accepted ) >=15
)
THEN
INSERT INTO user_badges( uid, bedge_id, is_active )
VALUES (
new.uid, '10', '1'
);
DELETE FROM user_badges WHERE uid = new.uid AND badge_id =9;
END IF ;
END IF ;
END
触发器:2:
DROP TRIGGER IF EXISTS `forumpostTrigger` ;
CREATE DEFINER = `livecomm`@`localhost` TRIGGER `forumpostTrigger` AFTER INSERT ON `forum_post`
FOR EACH
ROW BEGIN if( (
(
SELECT count( * )
FROM forum_post
WHERE uid = new.uid
AND parent_id IS NOT NULL
AND is_answer_accepted ) >=30
) && (
(
SELECT sum( vote_count )
FROM forum_post
WHERE uid = new.uid
AND parent_id IS NOT NULL
AND is_answer_accepted
) >=15
)
)
THEN
INSERT INTO user_badges( uid, bedge_id, is_active )
VALUES (
new.uid, '10', '1'
);
DELETE FROM user_badges WHERE uid = new.uid AND badge_id =9;
END IF ;
END
如何为 if 语句提供多个条件,例如:
if ((condition) && (condition))