need to do trigger after Inserting on a table called jos_jquarks_quizzes, I need to create a course name which will have the same name as the quizz name , but its own id,
Tables
jos_jquarks_quizzes
id title description course_id
jos_jquarks_users_training
id quiz_id user_id agree
So far My Trigger looks like this but has an error
-- Trigger DDL Statements
DELIMITER $$
USE `db_dhruniversity`$$
CREATE
TRIGGER `db_dhruniversity`.`ai_delete_course`
AFTER DELETE ON `jos_jquarks_开发者_运维百科quizzes`
FOR EACH ROW
BEGIN
DELETE FROM jos_jquarks_courses
WHERE (quiz_id = new.id);
END$$
In your where clause change new.id to old.id
-- Trigger DDL Statements
DELIMITER $$
USE `db_dhruniversity`$$
CREATE
TRIGGER `db_dhruniversity`.`ai_delete_course`
AFTER DELETE ON `jos_jquarks_quizzes`
FOR EACH ROW
BEGIN
DELETE FROM jos_jquarks_courses
WHERE (quiz_id = old.id);
END$$
精彩评论