What is a Function?
First off, what is a function?
A function is a block of code that does a certain job for us. For an analogy, think of the mathematical functions available in MS Excel. To add numbers, we can use the sum() function and type sum(A1:A5) instead of typing A1+A2+A3+A4+A5.
A function in MySQL is similar; it helps us accomplish certain tasks more easily.
MySQL provides us with a large number of pre-written functions that we can use in our SQL statements.
The full list of MySQL functions can be found at https://dev.mysql.com/doc/refman/8.0/en/built-in-function-reference.html.
Let’s look at some of them in this chapter.