When trying to create the trigger below, I get this message
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; END' at line 9
Can someone please help? Thank you
delimiter $$
CREATE TRIGGER tr_update_item_status
AFTER UPDATE ON check_in
FOR EACH ROW
BEGIN
IF OLD.quantity > 0 AND NEW.quantity <= 0 THEN
UPDATE check_in SET item_status = 'Sold';
ELSEIF OLD.quantity <= 0 AND NEW.quantity > 0 THEN
UPDATE check_in SET item_status = 'Available';
ENDIF;
END;$$
delimiter ;
This should work. All the best.