MYSQL after update trigger

MySQLtrigger

I am new to database trigger. I really have no idea why i cant update the Label if the Quantity more than equal to 1000

CREATE TRIGGER TRG_UPDATE_STATUS
AFTER UPDATE ON product
FOR EACH ROW
  BEGIN
    IF NEW.QuantitySold >= 1000 THEN
    SET NEW.Label = 'BestSeller'
    END IF
  END

Here is the trigger I have.

Best Answer

You can only make persistent changes to NEW in a before row trigger. An after trigger doesn't fire until the record has already been written to the table.

To change the data that will be written to the table, you must use a before row trigger. Changing NEW in an after row trigger is possible, but pointless, since the contents of NEW get written to the table before an after trigger executes, as is explained in the documentation.