MENU
UNION
SELECT ... UNION [ALL | DISTINCT] SELECT ... [UNION [ALL | DISTINCT] SELECT ...] |
A UNION statement combines the results from multiple SELECT statements. |
To use an ORDER BY or LIMIT clause for the entire UNION result, parenthesize the individual SELECT statements and place the ORDER BY or LIMIT clause at the end: (SELECT a FROM t1 WHERE a=100 AND b=5) UNION (SELECT a FROM t2 WHERE a=101 AND b=3) ORDER BY a LIMIT 15; |