![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How Can MySQL operator precedence affect result set?
MySQL follows operator precedence and it has the following list of operators, having the same precedence which is on the same line −
INTERVAL BINARY, COLLATE ! - (unary minus), ~ (unary bit inversion) ^ *, /, DIV, %, MOD -, + <<, >> & | =, <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN BETWEEN, CASE, WHEN, THEN, ELSE NOT &&, AND XOR ||, OR :=
For operators that occur at the same precedence level within an expression, evaluation proceeds from left to right.
Example
Following is an example which shows the effect of operator precedence on result set −
mysql> Select 5+3/2-2; +---------+ | 5+3/2-2 | +---------+ | 4.5000 | +---------+ 1 row in set (0.00 sec)
In the above evaluation, MySQL first evaluates /(div) because it is at higher precedence than +(Addition) or –(Subtraction).
Advertisements