In TSQL Tutorial OR Condition is used to check multiple
conditions and query returns result when any one condition is true. It can be
used in a SELECT, INSERT, UPDATE, or DELETE statement.
WHERE condition1
OR condition2
...
OR condition_n;
if we need to implement a scenario where we say these are the condition and
we want data when any of these conditions is true we implement or operator.
While returning the result if first condition is true SQL server won’t check
other conditions i.e. it moves to next condition only in case of earlier ones
failure.
Using with
SELECT Statement
Let say army is recruiting for their work force. As per
their norms they dont want to recruit the people who are either less than18
years or more than 30 years aur height less than 5 feet.
For example:
SELECT *
FROM People
WHERE Age < '18' or Age > 30 or height < 5;
Above query will return the result set which can be eliminated
from main result set to get eligible people for army recruitment.
No comments:
Post a Comment