Q: How to create a trigger for the table already being used CREATE TRIGGER abc
after insert ON visadetails
FOR EACH ROW update visadetails SET VisaId=concat(new.Occupation,'-',new.Vid);

insert into visadetails (Occupation,Destination) value("student","rome");

after creating trigger m not able to insert the value, it gives following error message

#1442 - Can't update table 'gallery' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.


A: No need for an update (which btw would have updated all rows in the table with the result of the concat() for the new row because of the missing where clause).
CREATE TRIGGER abc
after insert ON visadetails
FOR EACH ROW 
   SET new.VisaId=concat(new.Occupation,'-',new.Vid);

