Home > database > Mysql to help write a trigger, very urgent
Mysql to help write a trigger, very urgent
Time:09-29
Database using two tables and table structure is as follows:
Requirements: When new_table insert a row, there was a row if new_table1 can record the date and the item is found in the new_table, will new_table in accord with the date and the number of all the records of the item, synthetic material 1, 2, synthetic materials, synthetic materials 3 addition, total synthetic material is a synthetic material 1, 2 synthetic material, synthetic material 3 together, and then put all the synthetic materials 3 addition
If can't find in the new_table1 and new_table ingredients date and items conform to record, will be new_table assigned to the newly inserted the line data new_table1, and calculate the total synthetic materials (still is synthetic material 1, synthetic material 2, composite additive)
The total mean every moment, new_table1 same items on the same day there can be at most one record
I ask you, thank you
CodePudding user response:
Added, the table data is new_table, no data is new_table1
CodePudding user response:
When new_table insert a row -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- that trigger on new_table Will new_table in accord with the date and the number of all the records of the item, synthetic material 1, 2 synthetic material, synthetic material 3 add -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- you want to update is still new_table MySQL does not support such behavior