Use bitsCN.com for MYSQL triggers
Mysql triggers are in the format of create trigger trigger_name after/before insert/update/delete on one_table for each row your_ SQL. the red part is named by yourself, and the blue part is a value. The Black part is required, the final green part is the SQL statement you want to run. the update method for the two table join operations in mysql is (mysql does not use the join statement here): update A, B set. a2 = B. b2 where. a1 = B. b1 and B. b2 = "XXX" where A and B are the user-created table names a2 and b2 are the attribute values under the table. in mysql, the trigger is used to obtain the newly inserted data keyword, that is, (I have bad naming habits for databases): table1: records (accountid, date, month, week, income, expend, remark); table2: Rweek (week, Wincome, wexpend); trigger to insert a group of data for table1, table2 summarizes the corresponding week values: create trigger t1 after insert on records for each row update Rweek set Rweek. wincome = Rweek. wincome + NEW. income, Rweek. wexpend = Rweek. wexpend + NEW. expend where Rweek. week = NEW. week; author: ChanthonbitsCN.com
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.