---
title: "SQLite  - SELECT Query"  
description: "SQLite SELECT statement is used to fetch the data from a SQLite database table which returns data in the form of result table."  
author: "Tarun Kumar"  
published: 2015-09-08  
updated: 2019-03-31  
canonical: https://www.mindstick.com/articles/1858/sqlite-select-query  
category: "sqlite"  
tags: ["sqlite", "sqlite3"]  
reading_time: 3 minutes  

---

# SQLite  - SELECT Query

SQLite [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) is used to fetch the data from a [SQLite database](https://www.mindstick.com/articles/1554/crud-operation-in-asp-dot-net-using-sqlite-database) table which returns data in the form of result table. These result tables are also called result-sets.\

Syntax : The basic syntax of SQLite SELECT statement is as follows:

\

```
SELECT expressionsFROM tablesWHERE conditions;
```

##### \

##### However, the full syntax for the SQLite SELECT statement is:

\

```
SELECT [ ALL | DISTINCT ]expressionsFROM tablesWHERE conditions[ GROUP BY expressions ][ HAVING condition ][ ORDER BY expression [ ASC | DESC ] ][ LIMIT number_rows OFFSET offset_value ];
```

##### Parameters or Arguments

##### ALL : Optional. If specified, it returns all matching rows.

DISTINCT : Optional. If specified, it removes duplicates from the result set.\
Expressions : The columns or calculations that you wish to retrieve.\
Tables : The tables that you wish to retrieve records from. There must be at least [one table](https://www.mindstick.com/forum/538/copy-one-table-to-another-in-sql-server-automatically) listed in the FROM clause.\
Conditions : The conditions that must be met for the records to be selected.\
GROUP BY : Optional. It collects data across multiple records and groups the results by one or more columns.\
HAVING : Optional. It is used in combination with the GROUP BY to restrict the groups of returned rows to only those whose the [condition](https://www.mindstick.com/forum/12711/select-query-with-and-condition) is TRUE.\
ORDER BY : Optional. It is used to sort the records in your result set. Learn more about the ORDER BY clause.\
LIMIT : Optional. If LIMIT is provided, it [controls](https://www.mindstick.com/articles/66/how-to-create-controls-at-run-time-in-csharp-dot-net) the maximum number of records to retrieve. At most, the number of records specified by number_rows will be returned in the result set. The first row returned by LIMIT will be determined by offset_value.

##### Example - Select all fields from one table

```
SELECT * FROM employees WHERE employee_id< 150ORDER BY last_name ASC;
```

In this example, we've used * to signify that we wish to select all fields from the [employees](https://yourviews.mindstick.com/view/81150/corona-lockdown-let-s-worry-for-employees) table where the employee_id is less than 150. The result set is sorted by last_name in [ascending order](https://www.mindstick.com/forum/157178/how-to-filter-1000-of-student-name-in-php-in-ascending-order).

##### Example - Select individual fields from one table

## \

```
SELECT employee_id, last_name, first_name FROM employees WHERE employee_id < 150 ORDER BY last_name ASC, employee_id DESC;
```

In this example we fetch individual fields from the table, as opposed to all fields from the table. Here we would return only the employee_id, last_name, and first_name fields from the employees table where the employee_id is less than 150. The results are sorted by last_name in ascending order and then employee_id in [descending order](https://www.mindstick.com/forum/160082/how-to-sort-the-results-of-an-sql-search-query-in-ascending-and-descending-order).

##### Example - Select fields from multiple tables

## \

```
SELECT employees.employee_id, employees.last_name, positions.title FROM employees INNER JOIN positions ON employees.employee_id = positions.employee_id ORDER BY positions.title;
```

In this example we joins two tables together to gives us a result set that displays the employee_id, last_name, and title fields where the employee_id value matches in both the employees and positions table. The results are sorted by title in ascending order.

---

Original Source: https://www.mindstick.com/articles/1858/sqlite-select-query

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
