I'm using a trigger to store changes in an audit table, I only want to store the values from columns that have been changed.
BEGIN
IF NEW.history_of_repair_trigger_fired = 1 THEN
INSERT INTO history_of_repair SET
edit_date_time=NEW.last_edited_date_time,
edited_by=NEW.edited_by,
repair_id=NEW.repair_id,
tenant_name=NEW.tenant_name,
property_id=NEW.property_id,
priority=NEW.priority,
comments=NEW.comments,
signed_off=NEW.signed_off;
END IF;
END
At the moment this is storing the unchanged values in the audit table too, which is not desirable.
What's the best way of only storing the changed columns in my audit table?