Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Eliminating WHERE clauses with NOT
Message
From
04/11/2014 11:12:33
 
 
To
04/11/2014 10:59:28
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01610458
Message ID:
01610466
Views:
47
This message has been marked as a message which has helped to the initial question of the thread.
>>You can reverse last condition, e.g.
>>
>>select Name from dbo.Client
>>where NoProvince = @NoProvince and (NoStatus <> @NoStatus OR ModDate >=@ModDate)
>
>Yes, this is exactly what Sergey provided as information.
>
>I just do not understand how this provides the same result set. I see it is. It is just a question of knowing how can this be the same.

It's boolean algebra
NOT ( A and B) 

is

NOT(A) or NOT(B)
So
NOT (Client.NoStatus=@NoStatus AND Client.ModDate<@ModDate)

NOT( Client.NoStatus=@NoStatus ) OR NOT(Client.ModDate<@ModDate)

is
(Client.NoStatus <> @NoStatus) OR ( Client.ModDate>= @ModDate )
Also
NOT ( A or B)
is
NOT(A) and NOT(B)
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform