Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Table: table_user
- userid (primary key)
- no_changes_status (true means no update has been made on table_website for this userid)
- Table: table_website
- userid (reference key)
- website_url (when the value of this field is changed, no_changes_status should be set to false)
- DELIMITER $$
- CREATE TRIGGER testref BEFORE INSERT ON table_website
- FOR EACH ROW BEGIN
- SELECT @aff_rows:=COUNT(*) FROM table_website WHERE yourCondition = sameConditionUsedForYourInsert
- AND (
- OLD.col1 != NEW.col1 OR
- OLD.col2 != NEW.col2 ...);
- IF @aff_rows > 0 THEN
- UPDATE table_user SET no_changes_status = whatever WHERE whatever;
- END IF;
- END;
- $$
- DELIMITER ;
- SELECT ROW_COUNT();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement