Data Manipulation: SELECT, INSERT, UPDATE, DELETE
SELECT Syntax
SELECT [STRAIGHT_JOIN]
[SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS] [HIGH_PRIORITY]
[DISTINCT | DISTINCTROW | ALL]
select_expression,...
[INTO {OUTFILE | DUMPFILE} 'file_name' export_options]
[FROM table_references
[WHERE where_definition]
[GROUP BY {unsigned_integer | col_name | formula} [ASC | DESC], ...]
[HAVING where_definition]
[ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC] ,...]
[LIMIT [offset,] rows]
[PROCEDURE procedure_name]
[FOR UPDATE | LOCK IN SHARE MODE]]SELECT is used to retrieve rows selected from one or more tables. select_expression indicates the columns you want to retrieve. SELECT may also be used to retrieve rows computed without reference to any table. For example:
mysql> SELECT 1 + 1;
-> 2All keywords used must be given in exactly the order shown in the preceding example. For instance, a HAVING clause must come after any GROUP BY clause and before any ORDER BY clause.
A SELECT expression may be given an alias using AS. The alias is used as the expression’s column name and can be used with ORDER BY or HAVING clauses. For example:
mysql> SELECT CONCAT(last_name,', ',first_name) AS full_name FROM mytable ORDER BY full_name;You cannot use a column alias in a WHERE clause because the column value may not yet be determined when the WHERE clause is executed. See Section A.5.4.
The FROM table_references clause indicates the tables ...