PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.3Kb
Man Pages (Zip) - 402.5Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
Security in MySQL
Starting and Stopping MySQL
MySQL and Linux/Unix
MySQL and Windows
MySQL and macOS
MySQL and Solaris
Building MySQL from Source
MySQL Restrictions and Limitations
MySQL Partitioning
MySQL Tutorial
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL NDB Cluster 8.0
query_expression_body UNION [ALL | DISTINCT]query_block [UNION [ALL | DISTINCT]query_expression_body] [...]query_expression_body:See Section 15.2.14, “Set Operations with UNION, INTERSECT, and EXCEPT”UNION combines the result from multiple query blocks into a single result set. This example usesSELECT statements:
mysql> SELECT 1, 2;+---+---+| 1 | 2 |+---+---+| 1 | 2 |+---+---+mysql> SELECT 'a', 'b';+---+---+| a | b |+---+---+| a | b |+---+---+mysql> SELECT 1, 2 UNION SELECT 'a', 'b';+---+---+| 1 | 2 |+---+---+| 1 | 2 || a | b |+---+---+UNION Handing in MySQL 8.0 Compared to MySQL 5.7
In MySQL 8.0, the parser rules forSELECT andUNION were refactored to be more consistent (the sameSELECT syntax applies uniformly in each such context) and reduce duplication. Compared to MySQL 5.7, several user-visible effects resulted from this work, which may require rewriting of certain statements:
NATURAL JOINpermits an optionalINNERkeyword (NATURAL INNER JOIN), in compliance with standard SQL.Right-deep joins without parentheses are permitted (for example,
... JOIN ... JOIN ... ON ... ON), in compliance with standard SQL.STRAIGHT_JOINnow permits aUSINGclause, similar to other inner joins.The parser accepts parentheses around query expressions. For example,
(SELECT ... UNION SELECT ...)is permitted. See alsoSection 15.2.11, “Parenthesized Query Expressions”.The parser better conforms to the documented permitted placement of the
SQL_CACHEandSQL_NO_CACHEquery modifiers.Left-hand nesting of unions, previously permitted only in subqueries, is now permitted in top-level statements. For example, this statement is now accepted as valid:
(SELECT 1 UNION SELECT 1) UNION SELECT 1;Locking clauses (
FOR UPDATE,LOCK IN SHARE MODE) are allowed only in non-UNIONqueries. This means that parentheses must be used forSELECTstatements containing locking clauses. This statement is no longer accepted as valid:SELECT 1 FOR UPDATE UNION SELECT 1 FOR UPDATE;Instead, write the statement like this:
(SELECT 1 FOR UPDATE) UNION (SELECT 1 FOR UPDATE);
PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.3Kb
Man Pages (Zip) - 402.5Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
Security in MySQL
Starting and Stopping MySQL
MySQL and Linux/Unix
MySQL and Windows
MySQL and macOS
MySQL and Solaris
Building MySQL from Source
MySQL Restrictions and Limitations
MySQL Partitioning
MySQL Tutorial
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL NDB Cluster 8.0