Reputation: 10302
How can we count the total records of UNION of 2 select statement through query in MySql?
(select name, phone from table1) UNION (select name, phone from table2)
Upvotes: 1
Views: 511
Reputation: 263723
is this what you want? Your question is to unclear to me.
SELECT COUNT(*) as TotalRecordCount
FROM
(select name, phone from table1
UNION
select name, phone from table2) as UnionTable
Upvotes: 1
Reputation: 4346
You can use derived tables:
SELECT COUNT(*)
FROM (
(select name, phone from table1)
UNION
(select name, phone from table2)
) AS combined_table
UPD: here's a fiddle
Upvotes: 2
Reputation: 11623
You could do something like
SELECT COUNT(*) FROM
(
(select name, phone from table1) UNION (select name, phone from table2)
)
Upvotes: 0