From the course: MySQL Essential Training

Unlock this course with a free trial

Join today to access over 23,700 courses taught by industry experts.

Basic math

Basic math

- [Bill] Hi, I'm Bill Wyman. MySQL provides several simple functions for basic mathematical purposes. Of course, there's PI, I can say select PI and get the value of PI in this case to 7 places, which is the default. If I want more places, I simply add zero point however many places I want, 4, 5, I'll make it 10 or 15. There is a limit, and this is based on the limit of the standard double precision value in the computer. And if I try and go out to 20 places to the right of the decimal point, you see that I've hit that limit and I get the zeros out there. There's a power function for getting numbers raised to a power, so I can say 8, 2 and I get 8 raised to the second power, which is 8 squared or 64. And POW is an alias for power, same result. And I can use the reciprocal of the power, so I could say like 64, 1/2 and get the square root, or I could say 4096 to the fourth root and get 8. Of course, there is a square root function to make that simple, and it's spelled SQRT. So if I want…

Contents