For tables with the same fields in mysql (used by union), cross-table statistics are required when multiple tables are maintained and used, after query, you can use the union and union all statements to implement union and union all. They combine the content of multiple tables and then output them as one table. Their difference is that union removes duplicate rows, while union all retains all of them. Note that: the columns and columns in all queries must be in the same order (the list content can include column names, arithmetic expressions, Aggregate functions, etc) the data type must be compatible (the corresponding columns in the result set must have the same data type, or implicit data conversion exists between the two data types, or type conversion is provided). The following is an example: there are two tables, TA and TB. Each table has the Name column and Size column. The target is to display the Size and of each Name. The statement is as follows:
[SQL] select name, sum (size) from (select name, size from TA union select name, size from TB) alias group by name;
Alias is the alias of the union table in parentheses.