如何通过MySql中的查询计算2个select语句的UNION总记录?
(select name, phone from table1) UNION (select name, phone from table2)
答案 0 :(得分:2)
您可以使用派生表:
SELECT COUNT(*)
FROM (
(select name, phone from table1)
UNION
(select name, phone from table2)
) AS combined_table
UPD:这是fiddle
答案 1 :(得分:1)
SELECT COUNT(*) as TotalRecordCount
FROM
(select name, phone from table1
UNION
select name, phone from table2) as UnionTable
答案 2 :(得分:0)
您可以执行类似
的操作SELECT COUNT(*) FROM
(
(select name, phone from table1) UNION (select name, phone from table2)
)