Apologies for the vague title - hopefully this explains better:
The below trigger is firing after an update (as designed) but the two IF
statements are firing when neither the prospectid
or propertyid
fields are updated.
So the first question is, is there something wrong with the IF
logic? I do recall having some issues with <>
vs <=>
...?
CREATE TRIGGER myTrig AFTER UPDATE ON t_enquiries
FOR EACH ROW
BEGIN
IF (NEW.prospectid <=> OLD.prospectid) OR (NEW.propertyid <=> OLD.propertyid) THEN
IF (NEW.prospectid IS NOT NULL) AND (NEW.propertyid IS NOT NULL) THEN
INSERT INTO t_prospect_property_link (prospectid, propertyid, remaininginspections) VALUES (NEW.prospectid, NEW.propertyid, 10)
ON DUPLICATE KEY UPDATE subscribed = 1, remaininginspections = 10;
END IF;
END IF;
END
If my IF
statements are ok, surely this statement which fires the trigger isn't causing the prospectid
and propertyid
fields to do something to make the IF
evaluate true???
UPDATE t_enquiries SET recordstatus = 3, enquirystatus = 1 WHERE id = xxx;