in Databases retagged by
2,069 views
2 votes
2 votes

If an SQL query involves NOT,AND,OR with no parenthesis

  1. NOT will be evaluated first; AND will be evaluated second; OR will be evaluated last.
  2. NOT will be evaluated first; OR will be evaluated second; AND will be evaluated last.
  3. AND will be evaluated first; OR will be evaluated second;NOT will be evaluated last.
  4. The order of occurrence determines the order of evaluation.
in Databases retagged by
by
2.1k views

1 Answer

2 votes
2 votes

Operators having same precedence are placed in the same row.

SQL Operators:

  • Parenthesis ( )
  • DIVISION (/), MULTIPLICATION(*)
  • ADDITION (+), SUBSTRACTION(-)
  • NOT
  • AND
  • ALL, ANY, BETWEEN, IN, LIKE, OR

A gives the correct order of precedence.

This can be changed by using parenthesis, that is why questions clearly mentions no parenthesis is used.

Ref: http://www.sqlqueryexamples.com/sql-logical-operators-and-operator-precedence.htm

1 comment

This is exactly the same in the context of C -programming language,right ??
1
1