Friday, December 26, 2014

where clause

The first query will return a row if EMP_END_DATE is NULL and CURENT_ACTIVE_FLAG is either 1 or NULL. The second will return all rows with CURRENT_ACTIVE_FLAG = 1 or NULL. It will also return rows with CURRENT_ACTIVE_FLAG = 0 if EMP_END_DATE is NULL.


The reason for this is the same why


(2 + 3) * 5 = 25

2 + 3 * 5 = 17


That is, OR is a addition operator and ADD is a multiplication operator that binds harder.





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

No comments:

Post a Comment