SQLite AND
To make multiple comparisons with different operators in the same statement, the SQLite AND Operator are used. It is generally used with SELECT, UPDATE and DELETE statements. It is a conjunctive operator and is always used with the WHERE Clause.
Syntax:
SELECT column_1, column_2, column_N FROM table_name WHERE condition_1 AND condition_2...AND condition_N;
Example:
TEACHERS Table:
ID | NAME | AGE | SUBJECT |
1 | Jim | 27 | English |
2 | John | 30 | Geology |
3 | Watson | 28 | French |
4 | Holmes | 40 | Chemistry |
5 | Tony | 35 | Physics |
SELECT * FROM TEACHERS WHERE ID > 2 AND AGE >= 30; |
Output:
ID | NAME | AGE | SUBJECT |
2 | John | 30 | Geology |
4 | Holmes | 40 | Chemistry |
5 | Tony | 35 | Physics |
Explanation:
The “TEACHERS” is an already existing table. Here we are selecting those rows of the table where the value in the ID column is greater than 2 and the value in the AGE column is greater than or equal to 30.