SELECT
You are viewing an old version of this article. View
the current version here.
Syntax
SELECT [ALL | DISTINCT | DISTINCTROW] [HIGH_PRIORITY] [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT] [SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS] select_expr [, select_expr ...] [ FROM table_references [WHERE where_condition] [GROUP BY {col_name | expr | position} [ASC | DESC], ... [WITH ROLLUP]] [HAVING where_condition] [ORDER BY {col_name | expr | position} [ASC | DESC], ...] [LIMIT {[offset,] row_count | row_count OFFSET offset}] [PROCEDURE procedure_name(argument_list)] [ INTO OUTFILE 'file_name' [CHARACTER SET charset_name] export_options | INTO DUMPFILE 'file_name' | INTO var_name [, var_name] ] [FOR UPDATE | LOCK IN SHARE MODE] ]
Description
SELECT
is used to retrieve rows selected from one or more
tables, and can include UNION
statements and subqueries. See
UNION, and http://dev.mysql.com/doc/refman/5.1/en/subqueries.html.
The most commonly used clauses of SELECT
statements are these:
- Each select_expr indicates a column that you want to retrieve. There must be at least one select_expr.
table_references
indicates the table or tables from which to retrieve rows. Its syntax is described in JOIN.- The
WHERE
clause, if given, indicates the condition or conditions that rows must satisfy to be selected.where_condition
is an expression that evaluates to true for each row to be selected. The statement selects all rows if there is no WHERE clause.- In the
WHERE
clause, you can use any of the functions and operators that MySQL supports, except for aggregate (summary) functions. See http://dev.mysql.com/doc/refman/5.1/en/functions.html
- In the
SELECT can also be used to retrieve rows computed without reference to any table.
Comments
Comments loading...
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.