From the course: Quick Start Guide to SQL

Unlock the full course today

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

Order of precedence

Order of precedence

- [Instructor] Let's understand the order of precedence of all the conditions which we are using in, where. First, it's arithmetic operators, like multiplication, division, addition, and subtraction. Then it's the concatenation operator, which is two pipelines, then comes the comparison like equals, not equals, greater than, less than, greater than equals, less than equals. Then comes IS NULL, IS NOT NULL, LIKE, IN, NOT IN, followed by BETWEEN, NOT BETWEEN. Then comes the logical operators, NOT, and then AND, and finally, OR. Just like how we change the precedence of operators in the same way, we can change the precedence of conditions that we use in the where by using parenthesis. Let's look at a few examples. I'll write these select statements in Live SQL and then we will compare the two outputs. I give select EMP number, name, DPT number, salary from EMP tab where DPT number equals 30, or DPT number equals 40. And…

Contents