# SELECT

The `SELECT` statement is used to retrieve data from a table. See the [SELECT](https://docs.singlestore.com/db/v9.1/reference/sql-reference/data-manipulation-language-dml/select.md) page for more details such as syntax, remarks, and examples.

The `SELECT` clause specifies the columns to be retrieved from the table(s). All columns can be specified. Distinct (not repeated) values for a column can also be specified. The `SELECT` page gives details of the syntax for these options.

The following clauses make up the basic parts of a `SELECT` statement. The clauses are optional except for the `FROM` clause in most cases.

## The FROM Clause

The `FROM` clause specifies which table(s) data will be queried from. If multiple tables are queried, the subsequent table(s) that follow the first table will use a `JOIN` clause. See [JOIN and Subqueries](https://docs.singlestore.com/db/v9.1/reference/sql-reference/data-manipulation-language-dml/select/#join-and-subqueries.md)  for details about join syntax.

## The WHERE Clause

The `WHERE` clause specifies the conditions that must be met for a row to be included in the result set.&#x20;

## The GROUP BY and HAVING Clauses

The `GROUP BY` clause groups rows together that have the same values for columns listed in the `SELECT` clause. The GROUP BY clause must be used for columns not aggregated. See the [Aggregate Functions](https://docs.singlestore.com/db/v9.1/reference/sql-reference/aggregate-functions.md) section for more information on how to use the `GROUP BY` clause in queries that contain aggregate functions.

The `HAVING` clause is used to filter the results of queries that use a `GROUP BY` clause. The `HAVING` clause can refer to grouped and ungrouped columns.

## The ORDER BY Clause

The `ORDER BY` clause sorts the result set of a query based on one or more columns. Either ascending (`ASC`) or descending (`DESC`) can be specified. By default, if you don't specify `ASC` or `DESC`, the sort will be in ascending order.

## The LIMIT Clause

The `LIMIT` clause is used to restrict the number of rows returned in the result set to the number specified.

## Related Information

[SQL Functions List](https://docs.singlestore.com/db/v9.1/reference/sql-reference/sql-functions-list.md) - this is a list of all the SQL functions SingleStore current used. SQL Functions can be used in `SELECT` statements.

***

Modified at: June 22, 2023

Source: [/db/v9.1/query-data/select/](https://docs.singlestore.com/db/v9.1/query-data/select/)

(An index of the documentation is available at /llms.txt)
