Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Where statement wiht AND, OR

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2010-01-18 : 09:51:49
Once <and> + <or> using in where statement, it is always confising me.
For example, will the following statement get the same result?
1) update tblFruit
set color = 'other'
where month = 'Dec' and
(color not in ('red', 'yellow', 'green'))
update tblFruit
set color = 'other'
where month = 'Dec' and
color = ''
2) update tblFruit
set color = 'other'
where month = 'Dec' and
((color not in ('red', 'yellow', 'green'))
or (color = ''))

Does 1) get the same result as 2)?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-18 : 10:05:40
Yes. Why didn't you try it?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -