IFステートメントで2つの条件を指定しようとしています...以下の2つのトリガーは構文エラーを示していませんが、機能していません。
トリガー: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))