SQL Where Clause : Write boolean logic to satisfied the multiple condition
Scenario : For example if we have a Single Update statement and If we want to satisfied some condition based on some values.But at the same time this condition is not true if value is different than above condition should not applied.
UPDATE TEST
SET Salary=Salary+5000
WHERE Department='ALL'
AND (( JoinDate >= GetDATE()-365 AND Grade='C')
OR Grade<> 'C')
AND EmpStatus='ACTIVE'
Above query you can see one single boolean expression logic will satisfied both the condition.
No comments:
Post a Comment