## 13.2.10.4 Parenthesized Query Expressions 

parenthesized_query_expression : ( query_expression  [ order_by_clause ] [ limit_clause ] ) [ order_by_clause ] [ limit_clause ] [ into_clause ] query_expression : query_block  [UNION query_block  [UNION query_block  ...]] [ order_by_clause ] [ limit_clause ] [ into_clause ] query_block : SELECT ... (see Section 13.2.10, “SELECT Statement” ) order_by_clause : ORDER BY as for SELECT (see Section 13.2.10, “SELECT Statement” ) limit_clause : LIMIT as for SELECT (see Section 13.2.10, “SELECT Statement” ) into_clause : INTO as for SELECT (see Section 13.2.10, “SELECT Statement” ) 

MySQL 8.0.22 and higher supports parenthesized query expressions according to the preceding syntax. At its simplest, a parenthesized query expression contains a single SELECT  and no following optional clauses: 

(SELECT 1); (SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ’mysql’); 

A parenthesized query expression can also contain a UNION  comprising multiple SELECT  statements, and end with any or all of the optional clauses: 

mysql> (SELECT 1 AS result UNION SELECT 2); +--------+ | result | +--------+ | 1 | | 2 | +--------+ mysql> (SELECT 1 AS result UNION SELECT 2) LIMIT 1; +--------+ | result | +--------+ | 1 | +--------+ mysql> (SELECT 1 AS result UNION SELECT 2) LIMIT 1 OFFSET 1; +--------+ | result | +--------+ | 2 | +--------+ mysql> (SELECT 1 AS result UNION SELECT 2) ORDER BY result DESC LIMIT 1; +--------+ | result | +--------+ | 2 | +--------+ mysql> (SELECT 1 AS result UNION SELECT 2) ORDER BY result DESC LIMIT 1 OFFSET 1; +--------+ | result | +--------+ 

