TechCrunch

MobileCrunch

Gizmodo

My ADSL Broadband News - Internet, Telecoms, Gaming and Computer News

Pocket-lint

Thursday, September 9, 2010

SQL Operator Precedence

SYNTAX:

SELECT [ ALL | DISTINCT ]
[TOP ( expression ) [PERCENT] [ WITH TIES ] ]
column_list
[ INTO new_table ]
[ FROM { table_source } [ ,...n ] ]
[ WHERE expression1 operator expression2 -- eval highest level operators first
[ GROUP BY ]
[ HAVING search_condition ]
[ ORDER BY order_expression [ ASC | DESC ] 


PURPOSE:
Operator precedence determines the sequence that operations are performed when evaluating a complex expression.


LevelOperator
1inner parenthesis
2outer parenthesis
3~ (Bitwise NOT)
4* (Multiply), / (Division), % (Modulo)
5+ (Positive), – (Negative), + (Add), (+ Concatenate), – (Subtract), & (Bitwise AND), ^ (Bitwise Exclusive OR), | (Bitwise OR)
6 =, >, < , >=, < =, <>, !=, !>, !< (Comparison operators)
7NOT
8AND
9ALL, ANY, BETWEEN, IN, LIKE, OR, SOME
10 = (Assignment)

NOTE: When operators are at same level, proceed left to right – just as in reading.

Search TechTalk

 
TwitterWind: a Twitter widget