I am trying to create a TRIGGER that will update a table after updating another table. I need it so that if a number in the number column is updated, then this needs to be recorded in another table. This is what I have so far..
DELIMITER $$
CREATE TRIGGER record_update_to_user_number
    AFTER UPDATE ON user FOR EACH ROW
    IF (NEW.number != OLD.number) THEN//if new updated number is not equal t                                    to  number currently in the table then..
        DECLARE insertednumber TINYINT;  //variable to store updated num
        SET insertednumber = NEW.number;
        INSERT INTO user_changes (username, currentdate, numberchange)
        VALUES (current_user(), CURDATE(), insertednumber);
    END IF;
    DELIMITER ;
Test update to table:
UPDATE user SET number='69' WHERE number='68'; //test update to table
As you can see, I'm trying to store the newly inserted user number into a variable which will then be used to populate the insertednumber column of the user_changes table. Any help would be greatly appreciated, thanks!
 
     
    