From the course: MySQL Essential Training (2019)

Unlock this course with a free trial

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

Operator precedence

Operator precedence

- [Instructor] If you have an expression with more than one operator it can be valuable to understand the order in which the operators will be evaluated. This is called operator precedence. For example, if I say select and then give an expression, say, five plus six times seven minus eight. And when I execute it I'll get this result, 39. Now, if put parentheses around the addition operation and the subtraction operation, I'll get an entirely different result when I execute. Now it's minus 11. This is because the parentheses force the system to evaluate those expressions first. If instead, I put the parentheses around the multiplication, and execute, we get 39 again. And this is because the multiplication already has higher precedence than addition or subtraction. A common way to remember the precedence of most common operators is with the mnemonic PEDMAS. Parentheses, exponents, division, multiplication, addition and subtraction. This is the common order in both mathematics and…

Contents