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.
| Author |
Topic |
|
binggeli
Starting Member
20 Posts |
Posted - 2005-11-23 : 09:54:47
|
| Why does this query return data from other ClientID's as well?SELECT TOP 111 * FROM Users WHERE ClientID = 'INGBANK' AND TermDate IS NULLAND isGroup IS NULL OR isGroup = 0But this one gives me the correct data(only data from the specified ClientID):SELECT TOP 111 * FROM Users WHERE ClientID = 'INGBANK' AND TermDate IS NULLAND (isGroup IS NULL OR isGroup = 0)What am I doing wrong in the first query? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-23 : 09:57:34
|
| First query is treated as SELECT TOP 111 * FROM Users WHERE ClientID = 'INGBANK' AND (TermDate IS NULLAND isGroup IS NULL) OR isGroup = 0MadhivananFailing to plan is Planning to fail |
 |
|
|
binggeli
Starting Member
20 Posts |
Posted - 2005-11-23 : 10:22:31
|
| The light came on.Thank you very much! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-23 : 23:46:03
|
| If there are lot of ANDs and ORs then better to use braces to get the proper resultMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|