I have a WEBSITE table like so:
WEBSITE
web ID | url | progress
-------------------------------
1 | example.com | 67
I have a PROGRESS table like so:
PROGRESS
progress id | linking website id | amount to increase
---------------------------------------------------
1 | 1 | 60
2 | 1 | 7
When a row is inserted into PROGRESS using INSERT INTO,
I use php and mysql to get the accumulative values FROM the PROGRESS table, and then store the new value into the progress value FROM the WEBSITE table.
HOWEVER…
I was wondering if I could use these triggers I’ve been hearing about to automatically sum up the new progress value and store it?
Is this possible?
You don’t really need to use a trigger, you can just add the progress to the existing row in
websitebut if you wanted to try a trigger you can use the followingYou can also find further information on the syntax and use of triggers in on the manual page 12.1.11. CREATE TRIGGER Syntax