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
SQLite logical operators are as follows in a table format:
|SQLite Logical 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.
|The OR operator combines multiple conditions in the WHERE clause, which returns true if at least one of the specified conditions is true.
|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.
|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.
|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.
|The BETWEEN operator is used to search for values within the range of values.
|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.
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
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 on this website:
For more information on SQLite, visit the official website: