database - MySQL Column Update with trigger -
i have reservation table has reservation_id , room_num, date_start , date_end , cost columns. want insert columns except cost , fill cost automatically.
delimiter // create trigger upd_check before insert on reservation each row begin if new.reservation_cost = null set new.reservation_cost = 'timestampdiff(day, new.reservation_startd, new.reservation_endd)*70'; end if; end;// delimiter ; i wrote trigger it, whenever press apply insert nothing inserted reservation_cost column.
why?
i put in comment if had enough reputation, anyways. triggers cannot act on same table activated them. seems limiting, we've had same issue.
this link doesn't explicitly say "in associated table". not same: https://dev.mysql.com/doc/refman/5.0/en/triggers.html
Comments
Post a Comment