Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Eliminating WHERE clauses with NOT
Message
De
04/11/2014 11:12:33
 
 
À
04/11/2014 10:59:28
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01610458
Message ID:
01610466
Vues:
45
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform