I've got a table like this
id firstname lastname fullname
1 alex car alex car
2 tony table tony table
If the firstname or lastname gets changed I want that the database automatically changes the fullname too.
I tried it with this trigger
CREATE TRIGGER mytrigger
AFTER UPDATE
ON mytable FOR EACH ROW
BEGIN
UPDATE `mydb`.`mytable` SET `fullname` = CONCAT(NEW.firstname, " ",NEW.lastname)
END;
But I get this error:
#1442 - Can't update table 'mytable' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
Thanks you.