I have to create trigger in my SQLite database.
There are 3 tables in database
questions (question_id)options (option_id, question_id)answers (answer_id, question_id)
Whenever any row is deleted from question table, the corresponding data should also be deleted from option and answer tables.
I am trying to create trigger using
CREATE TRIGGER question_delete
BEFORE DELETE ON questions
FOR EACH ROW BEGIN
DELETE from options WHERE question_id= OLD.question_id AND
DELETE from answers WHERE question_id= OLD.question_id;
END
I get an error. Should I create two different trigger to perform this operation or any changes are required in above statement?
Please let me know.
Thanks Nidhi