
CodePudding user response:
select name, sum number (table 1) as table 1 record number, the sum number (table 2) as in table 2 record number,
Number the sum (table 1) + sum number (table 2) as the total number of records
The from (
Select name, count (*) as table 1 record number, number 2 0 as table from tb1 group by name
Union all
Select the name, number 1 0 as table, the count (*) number 2 as table from tb2 group by name
) a
Group by name