From the course: MySQL Database Administration

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

Challenge: Triggers

Challenge: Triggers

- [Instructor] All right, we are ready for your assignment on triggers. Again, you'll be working with Joe Tidyman, the owner of Sloppy Joe's Restaurant. Joe would like you to set up a trigger that will automatically update the number of orders served in the staff table anytime we serve another order, and a record is written to the customer orders table. So take a look at what you see on the right. If you run a select star from staff, you'll see that there is a summary column that tells the total number of orders they've served. That's the field that Joe wants you to update every time a new customer order gets written into the customer orders table. So if we were to insert these four records, we should see one additional record served by the employee with staff ID equals one and three additional records served by the employee with staff ID equals two. And if you have successfully created the trigger, then run that insert into statement, then run a select star from staff. You should see…

Contents