I'm trying to update the table with some values incremented by 10 in one column when I insert into each values in the same table.
the table looks like this original table
I want to update the cost column with the value of id multiplied by 10
Final table should look like this the table i want
I'm adding a trigger to do this but this isn't working
DELIMITER // Create Trigger cost after INSERT ON myTable FOR EACH ROW BEGIN update myTable set cost=id*10; END //
I'm getting this error insert into myTable(name,cost) values('s',0) Error Code: 1442. Can't update table 'myTable' in stored function/trigger because it is already used by statement which invoked this stored function/trigger. 0.000 sec
I'm using MySql