SQLite Logical Operators
SQLite Logical Operators
In this tutorial, we will learn about SQLite Logical operations with some examples. We can use logical operators in database queries to perform logical operations.
SQLite logical operators are as follows in a table format:
SQLite Logical Operator |
Name | Description |
AND | AND Operator | The AND operator combines multiple conditions in the database query WHERE clause, and it returns true only if all the specified conditions are true. |
OR | OR Operator | The OR operator combines multiple conditions in the WHERE clause, which returns true if at least one of the specified conditions is true. |
NOT | NOT Operator | The NOT operator is a negation operator. It is used to negate a condition. It returns true if the specified condition is false, and vice versa. |
IN | NOT IN Operator | The IN operator checks if a value matches any value in a specified list. The operator returns true if the value is present in the list. |
NOT IN | IN Operator | The NOT IN operator is the reverse of the IN operator. It checks if a value matches any value in a specified list. The operator returns true if the value is not present in the list. |
BETWEEN | BETWEEN Operator | The BETWEEN operator is used to search for values within the range of values. |
LIKE | LIKE Operator | The LIKE operator searches for a specified pattern in a WHERE clause. It is used to compare a value to similar values using wildcard operators. |
Example
In this example, we will demonstrate the usage of the AND operator.
sqlite> SELECT * FROM emp;
sqlite> SELECT * FROM emp WHERE jobtitle=’SALESMAN’
…> AND salary > 4000;
empno ename jobtitle salary
—– ———– ——– ——
6 Gopal Kumar SALESMAN 4500
sqlite>
The AND operator combines two logical conditions in the WHERE clause.
jobtitle = ‘SALESAMAN’ and salary > 4000
The query results will return the rows where both conditions are true.
—
SQLite Tutorials
SQLite tutorials on this website:
https://www.testingdocs.com/sqlite-database-tutorials/
For more information on SQLite, visit the official website: