sql - Making triggers in mySQL -
i'm new triggers , mysql, , there question asked part of class make trigger support inserting new "invoice" apart of database, , automatically update customer in 'customer' table adding new invoice onto customer balance attribute.
sorry if question isn't clear can answer details need clarifying.
example of customer, , invoice table following.
create table customer ( id int, ... transaction_count int default 0 ); create table invoice ( id int, customer_id int, ... ); and trigger this.
delimiter $$ create trigger invoice_counter after insert on invoice each row begin insert customer set transaction_count = transaction_count + 1 id = new.customer_id; end $$ delimiter ; following link more useful.
when need deeper on trigger
Comments
Post a Comment