MySQL Tutorials - Herong's Tutorial Examples - Version 4.20, by Dr. Herong Yang
A tutorial example is provided on how to use SELECT statements to retrieve from database as multiple rows and multiple fields in each row.
A select statement is also called a query statement. It is normally used to retrieve rows of data selected from specified tables. The generic syntax of a select statement is:
SELECT select_expression_list [FROM clause]
where "expression_list" defines a list of select expressions, and "FROM clause" defines a select table with rows and columns of values. Column names of the select table can be used as variables in select expressions to represent column values in each row.
When a select statement is executed, a nested loop logic will be performed to generate rows of output data:
Loop on each row of the select table, do: Loop on each select expression, do: Evaluate this expression with possible column values in current row of the select table. End of loop Return the results of all select expressions as a row of output data End of loop
Sample select statements without FROM clause:
SELECT 'Hello world!'; SELECT 'Apple', 'Orange'; SELECT CHAR_LENGTH('Hello world!'); SELECT 1, 4, 9, 16, 25; SELECT PI(); SELECT CURRENT_DATE(), CURRENT_TIME();
Last update: 2015.
Table of Contents