Friday, 15 July 2011

SQL Server OR precedence clarification? -



SQL Server OR precedence clarification? -

i reading this question logical operators or , in status , order of conditions in where

however extend question .

question 1 :

if (condition 1) or (condition 2)

i'm not talking if status 1 true, status 2 checked

but - possible sql select row based on condition 2 ( sec phrase) rather condition 1 first phrase ?

for illustration :

columna columnb 2 2

select * table id=columna or id=columnb

now , possible got row beucuse evaluated first id=columnb

question 2 :

this question talks where clause. bring together ? these roles apply

select * table1 bring together table2 on table1.id=table2.id or table1.aa = table2.aa

if status 1 true, status 2 checked? is possible sql yield row based on condition 2 ( sec phrase) rather condition 1 first phrase

i don't understand parts of question asking yielding rows, part can reply far is:

if status 1 true, status 2 checked

it depends. may, may not. there's no guarantee of short-circuiting or evaluation order parts of sql statement.

sql-server sql-server-2008

No comments:

Post a Comment