SQL SELECT Statement
A SQL SELECT Statement is a data querying statement that is a SQL statement (expressed in a SQL language).
- Context:
- It can (typically) be a Declarative Query.
- It can be a SQL SELECT JOIN Statement.
- Example(s):
SELECT colX AS age, COUNT(*) FROM tableP GROUP BY col2 ;
SELECT * FROM tableA, tableB WHERE tableA.a1 = tableB.b2 ;
- a HiveQL SELECT Statement.
- a Recursive SQL Query, such as with common table expressions.
- …
- Counter-Example(s):
- See: XQuery Query, CQL Query.
References
2013
- http://en.wikipedia.org/wiki/SQL#Queries
- The most common operation in SQL is the query, which is performed with the declarative
SELECT
statement.SELECT
retrieves data from one or more tables, or expressions. StandardSELECT
statements have no persistent effects on the database. Some non-standard implementations ofSELECT
can have persistent effects, such as theSELECT INTO
syntax that exists in some databases.[1]Queries allow the user to describe desired data, leaving the database management system (DBMS) responsible for planning, optimizing, and performing the physical operations necessary to produce that result as it chooses.
A query includes a list of columns to be included in the final result immediately following the
SELECT
keyword. An asterisk ("*
") can also be used to specify that the query should return all columns of the queried tables.
- The most common operation in SQL is the query, which is performed with the declarative
- http://en.wikipedia.org/wiki/Select_%28SQL%29
- The SQL SELECT statement returns a result set of records from one or more tables.[2][3]
A SELECT statement retrieves zero or more rows from one or more database tables or database views. In most applications,
SELECT
is the most commonly used Data Manipulation Language (DML) command. As SQL is a declarative programming language,SELECT
queries specify a result set, but do not specify how to calculate it. The database translates the query into a “query plan” which may vary between executions, database versions and database software. This functionality is called the “query optimizer” as it is responsible for finding the best possible execution plan for the query, within applicable constraints.The SELECT statement has many optional clauses:
WHERE
specifies which rows to retrieve.GROUP BY
groups rows sharing a property so that an aggregate function can be applied to each group.HAVING
selects among the groups defined by the GROUP BY clause.ORDER BY
specifies an order in which to return the rows.
- The SQL SELECT statement returns a result set of records from one or more tables.[2][3]
- ↑ "Transact-SQL Reference". SQL Server Language Reference. SQL Server 2005 Books Online. Microsoft. 2007-09-15. http://msdn2.microsoft.com/en-us/library/ms188029(SQL.90).aspx. Retrieved 2007-06-17.
- ↑ Microsoft. "Transact-SQL Syntax Conventions". http://msdn2.microsoft.com/en-us/library/ms189499.aspx.
- ↑ MySQL. "SQL SELECT Syntax". http://dev.mysql.com/doc/refman/5.0/en/select.html.