In this case we will always have a line, because even here we used functions of the column. The columns, however, will be two, because we asked two values: the number of rows and the maximum value of Column1. The presence of the WHERE clause causes are included in the count only the rows where the value in column2 is the same as specified. Let's look at the syntax of the SELECT (some terms are omitted for simplicity):
Code:
SELECT
[ALL | DISTINCT | DISTINCTROW]
expression, ...
[INTO OUTFILE 'file_name' options
| INTO DUMPFILE 'file_name']
[FROM tables
[WHERE conditions]
[GROUP BY {column_name | expression | position}
[ASC | DESC], ... [WITH ROLLUP]]
[HAVING conditions]
[ORDER BY {column_name | expression | position}
[ASC | DESC], ...]
[LIMIT [offset,] row_number]
As you can see, the basic structure of a SELECT statement is as follows:
- SELECT followed by one or more expressions that will be the columns of the table result;
- FROM followed by the names of one or more tables from which data must be extracted
- WHERE clause that specifies the conditions under which each line will be drawn from the tables or not
- GROUP BY specifies columns whose values should be grouped on the rows in the result: all rows with equal values will be reduced to a
- HAVING clause that specifies additional requirements to be applied to rows after the grouping made by the GROUP BY
- ORDER BY clause that specifies the order in which rows appear in the resultset
- LIMIT sets the maximum number of rows to extract
You can omit any part of the FROM and then to perform very simple queries do not refer to any table, for example:
that extracts the current date and time.
Bookmarks