I'm trying to use an After Update trigger to compare two column in my table (custom_avail_history) and if they do not match, insert the record into another table (custom_avail_history_changelog) to track changes over time. When I try using the code below it tells me "ERROR 1054: 1054: Unknown column 'cah_avail' in 'field list'" 'cah_avail' is a column in the table being updated and i've check the spelling and there are no extra spaces or anything like that. I'm new to using triggers so my code may be way off. If someone could point me in the right direction, I would greatly appreciate it. Thanks
Code:
CREATE DEFINER=`user123`@`%` TRIGGER `import`.`custom_avail_history_AFTER_UPDATE` AFTER UPDATE ON `custom_avail_history` FOR EACH ROW
BEGIN
IF (cah_avail <> cah_prevail) then
INSERT INTO custom_avail_history_changelog (cahc_variety, cahc_avail, cahc_prevail) VALUES (cah_variety, cah_avail,
cah_prevail);
End if;
END