SQL Logical Operators (And, Or, Like, In, Between, Exists, Not, ALL, Any)

Here we will learn what are the logical operators in SQL server and how to use logical operators in SQL select statements or queries with examples

SQL Logical Operators

In SQL, logical operators are useful to perform some conditional and comparison checks in SQL statements. In logical operators we have a different type of operators available, those are 

 

For more information related to logical operators in SQL server check following information

 

OperatorDescription
AND The AND operator in SQL is used to compare data with more than one condition. If all the conditions return TRUE then only it will display records.
OR The OR operator in SQL is used to compare data with more than one condition. If either of the condition is TRUE it will return data.
ALL The ALL operator in SQL returns true when value matches all values in a single column set of values. It’s like AND operator it will compare the value against all values in column.
ANY The Any operator in SQL returns true when the value matches any value in single column set of values. It’s like an OR operator and it will compare value against any value in the column.
LIKE The LIKE operator in SQL is used to search for character string with the specified pattern using wildcards in a column.
IN The IN operator in SQL is used to search for specified value matches any value in set of multiple values.
BETWEEN The BETWEEN operator in SQL is used to get values within a range.
EXISTS The EXISTS operator in SQL is used to show the result if the subquery returns data.
NOT The NOT operator in SQL is a negate operator that means it will show data for opposite of conditions that we mentioned in SQL statement.
SOME The SOME operator in SQL is used to compare value with a single column set of values returned by subquery. SOME must match at least one value in a subquery and that value must be preceded by comparison operators.