SQL Logical Operators
Logical Operators in SQL are used to combine or manipulate conditions in SQL queries to retrieve or manipulate data based on specified criteria..
Operator | Description |
---|---|
AND |
Logical AND compares two Booleans as expressions and returns true when both expressions are true. |
OR |
Logical OR compares two Booleans as expressions and returns true when one of the expressions is true. |
NOT |
Not takes a single Boolean as an argument and change its value from false to true or from true to false. |
SQL Logical Operators Example
In this example, retrieve all records from the “employee” table where the “emp_city” column is equal to ‘Allahabad’ and the “emp_country” column is equal to ‘India’.
SELECT * FROM employee WHERE emp_city =
'Allahabad' AND emp_country = 'India';
Output:
SQL Operators
SQL Operators perform arithmetic, comparison, and logical operations to manipulate and retrieve data from databases.
In this article, we will discuss Operators in SQL with examples, and understand how they work in SQL.