---
title: "AND and OR Operators of SQLite"  
description: "In this blog we will discuss about SQLite AND and OR operators are that are used to execute multiple conditions to narrow down the selected data in an"  
author: "Tarun Kumar"  
published: 2015-09-18  
updated: 2018-03-13  
canonical: https://www.mindstick.com/blog/10952/and-and-or-operators-of-sqlite  
category: "sqlite"  
tags: ["database", "sqlite", "sqlite3"]  
reading_time: 5 minutes  

---

# AND and OR Operators of SQLite

In this blog we will discuss about SQLite AND and OR [operators](https://www.mindstick.com/articles/716/php-operators) are that are used to execute [multiple conditions](https://www.mindstick.com/forum/1667/multiple-conditions-in-if-statement-or-splitting-using-c-sharp) to narrow down the selected data in an SQLite statement. Both of these two operators [known as](https://answers.mindstick.com/qa/35703/ricky-ponting-is-also-known-as-what) conjunctive operators. AND and OR operators also used for making multiple comparisons with different operators with the same SQLite statement.

AND Operator: AND operator allows the existence of multiple conditions in an SQLite statement's [WHERE clause](https://www.mindstick.com/interview/1909/when-do-you-use-where-clause-and-when-do-you-use-having-clause). AND returns TRUE if both inputs are TRUE (if 'this' AND 'that' are true). (1) AND (0) would evaluate to zero because one of the inputs is false (both must be TRUE for it to evaluate to TRUE). (1) AND (1) evaluates to 1. (any number but 0) AND (0) evaluates to 0. All of the above means that If, and only if, both [expressions](https://www.mindstick.com/forum/33876/what-is-the-syntax-for-lambda-expressions-in-vb-dot-net) evaluate to True, result is True. If either [expression](https://www.mindstick.com/articles/1861/sqlite-expressions) evaluates to False, result is False.

##### The following table illustrates how result is determined:

| If expression1 is | And expression2 is | The result is |
| --- | --- | --- |
| True | True | True |
| True | False | False |
| True | Null | Null |
| False | True | False |
| False | False | False |
| False | Null | False |
| Null | True | Null |
| Null | False | False |
| Null | Null | Null |

##### Syntax:

## \

```
SELECT column1, column2, columnN FROM table_nameWHERE [condition1] AND [condition2]...AND [conditionN];
```

We can combine N number of conditions using AND operator. For an action to be taken by the SQLite statement, whether it be a [transaction](https://www.mindstick.com/blog/175/transactions-in-database) or query, all conditions separated by the AND must be TRUE.

**Example**: there is an example of COMPANY table which has following records:

\

| **ID** | **NAME** | **AGE** | **ADDRESS** | **SALARY** |
| --- | --- | --- | --- | --- |
| 1 | Ajay | 32 | Calcutta | 20000.0 |
| 2 | Vijay | 25 | Delhi | 15000.0 |
| 3 | Vinay | 23 | Varansi | 20000.0 |
| 4 | Subhash | 25 | Punjab | 65000.0 |
| 5 | Suresh | 27 | Lucknow | 85000.0 |
| 6 | Preeti | 22 | Mumbai | 45000.0 |
| 7 | Neetu | 24 | Raebareli | 10000.0 |

Here is an example of AND operator with [SELECT statement](https://www.mindstick.com/forum/160076/explain-the-sql-select-statement-and-how-it-s-used-to-search-for-data-in-a-database) that lists down all the records where AGE is greater than or equal to 25 AND salary is greater than or equal to 65000.00:

```
sqlite> SELECT * FROM COMPANY WHERE AGE >= 25 AND SALARY >= 65000;
```

| ## ID | ## NAME | ## AGE | ## ADDRESS | **SALARY** |
| --- | --- | --- | --- | --- |
| 4 | Subhash | 25 | Punjab | 65000.0 |
| 5 | Suresh | 27 | Lucknow | 85000.0 |

OR Operator: OR operator is also used to [combine multiple](https://www.mindstick.com/forum/160929/help-with-writing-a-query-to-combine-multiple-rows-into-one-in-sql-server) conditions in an SQLite statement's WHERE clause. While using OR operator, complete [condition](https://www.mindstick.com/forum/12711/select-query-with-and-condition) will be assumed true when at least any of the the conditions is true. For example, [condition1] OR [condition2] will be true if either condition1 or condition2 is true. If either or both expressions evaluate to True, result is True.

##### The following table illustrates how result is determined:

## \

| If expression1 is | And expression2 is | Then result is |
| --- | --- | --- |
| True | True | True |
| True | False | True |
| True | Null | True |
| False | True | True |
| False | False | False |
| False | Null | Null |
| Null | True | True |
| Null | False | Null |
| Null | Null | Null |

##### Syntax:

**\**

```
SELECT column1, column2, columnN FROM table_nameWHERE [condition1] OR [condition2]...OR [conditionN]
```

\

We can combine N number of conditions using OR operator. For an action

to be

taken by the SQLite statement, whether it be a transaction or query, only

any ONE

of the conditions separated by the OR must be TRUE.

**Example**: Consider COMPANY table is having the following records:

\

| ## ID | ## NAME | ## AGE | ## ADDRESS | ## SALARY |
| --- | --- | --- | --- | --- |
| 1 | Ajay | 32 | Calcutta | 20000.0 |
| 2 | Vijay | 25 | Delhi | 15000.0 |
| 3 | Vinay | 23 | Varansi | 20000.0 |
| 4 | Subhash | 25 | Punjab | 65000.0 |
| 5 | Suresh | 27 | Lucknow | 85000.0 |
| 6 | Preeti | 22 | Mumbai | 45000.0 |
| 7 | Neetu | 24 | Raebareli | 10000.0 |

Here is an example of OR operator with SELECT statement that lists down all the records where AGE is greater than or equal to 25 OR salary is greater than or equal to 65000.00:\

```
sqlite> SELECT * FROM COMPANY WHERE AGE >= 25 OR SALARY >= 65000;
```

| ## ID | ## NAME | ## AGE | ## ADDRESS | ## SALARY |
| --- | --- | --- | --- | --- |
| 1 | Ajay | 32 | Calcutta | 20000.0 |
| 4 | Subhash | 25 | Punjab | 65000.0 |
| 5 | Suresh | 27 | Lucknow | 85000.0 |

---

Original Source: https://www.mindstick.com/blog/10952/and-and-or-operators-of-sqlite

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
