Oracle 5.0 Reference Manual page 1103

Table of Contents

Advertisement

You are permitted to specify
referenced:
mysql>
SELECT 1 + 1 FROM DUAL;
-> 2
is purely for the convenience of people who require that all
DUAL
and possibly other clauses. MySQL may ignore the clauses. MySQL does not require
FROM
if no tables are referenced.
DUAL
In general, clauses used must be given in exactly the order shown in the syntax description. For
example, a
clause must come after any
HAVING
clause. The exception is that the
immediately following the
"SELECT ... INTO
Syntax".
The list of
select_expr
Terms specify a column or expression or can use *-shorthand:
• A select list consisting only of a single unqualified
from all tables:
SELECT * FROM t1 INNER JOIN t2 ...
can be used as a qualified shorthand to select all columns from the named table:
tbl_name.*
SELECT t1.*, t2.* FROM t1 INNER JOIN t2 ...
• Use of an unqualified
problem, use a qualified
SELECT AVG(score), t1.* FROM t1 ...
The following list provides additional information about other
A
can be given an alias using
select_expr
expression's column name and can be used in
example:
SELECT CONCAT(last_name,', ',first_name) AS full_name
FROM mytable ORDER BY full_name;
The
keyword is optional when aliasing a
AS
could have been written like this:
SELECT CONCAT(last_name,', ',first_name) full_name
FROM mytable ORDER BY full_name;
However, because the
two
expressions: MySQL interprets the second as an alias name. For example, in the
select_expr
following statement,
SELECT columna columnb FROM mytable;
For this reason, it is good practice to be in the habit of using
aliases.
It is not permissible to refer to a column alias in a
yet be determined when the
Aliases".
The
FROM table_references
If you name more than one table, you are performing a join. For information on join syntax, see
Section 13.2.8.2,
"JOIN
SELECT
as a dummy table name in situations where no tables are
DUAL
clause can appear either as shown in the syntax description or
INTO
list. For more information about INTO, see
select_expr
terms comprises the select list that indicates which columns to retrieve.
with other items in the select list may produce a parse error. To avoid this
*
reference
tbl_name.*
is optional, a subtle problem can occur if you forget the comma between
AS
is treated as an alias name:
columnb
clause is executed. See
WHERE
clause indicates the table or tables from which to retrieve rows.
Syntax". For each table specified, you can optionally specify an alias.
1083
Syntax
SELECT
clause and before any
GROUP BY
can be used as shorthand to select all columns
*
SELECT
alias_name. The alias is used as the
AS
GROUP
BY,
ORDER
with an identifier. The preceding example
select_expr
explicitly when specifying column
AS
clause, because the column value might not
WHERE
Section C.5.5.4, "Problems with Column
statements should have
FROM
ORDER BY
Section 13.2.8.1,
clauses:
BY, or
clauses. For
HAVING

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents