Chapter 11: Control Flow Tools

 

Now that we know how to write basic stored routines, let us move on to a slightly more advanced concept.

 

In the previous chapter, we looked at a simple function for calculating the bonuses of employees. What if we want to perform more complex calculations?

 

For instance, suppose we want to pay 2 months bonus for employees with salary below 3000, but 1 month bonus for employees with salary above that?

 

In order to achieve the above, we need to use control flow tools. These include IF, CASE, and LOOP statements.

 

In this chapter, we’ll be using a lot of examples to illustrate the concepts discussed. For each example, I’ll leave a line before and after the control flow statements so that you can see clearly ...

Get Learn SQL using MySQL in One Day and Learn It Well now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.