Let’s talk about UNION first, which is used to combine the results of multiple different select statement executions into one result set and return it. Please refer to the official documentation. Understanding this, this statement can be split into 3 different select statements:
As for how to write this SELECT statement, you can first read the official instructions. Except for at least one select_expr, other parts of the SELECT statement can be omitted, which means that this way of writing is legal first (SELECT can also be used to retrieve rows computed without reference to any table.). So what does it do? To put it simply, you can understand that MySQL is a calculator at this time. With the functions provided by MySQL, it can be used to do various calculations and return the final calculation result after successful execution. Example:
Let’s talk about UNION first, which is used to combine the results of multiple different select statement executions into one result set and return it. Please refer to the official documentation. Understanding this, this statement can be split into 3 different select statements:
As for how to write this SELECT statement, you can first read the official instructions. Except for at least one select_expr, other parts of the SELECT statement can be omitted, which means that this way of writing is legal first (SELECT can also be used to retrieve rows computed without reference to any table.). So what does it do? To put it simply, you can understand that MySQL is a calculator at this time. With the functions provided by MySQL, it can be used to do various calculations and return the final calculation result after successful execution. Example: