需要查三个表,分别是票务商品表 抽奖商品表 积分兑换表 现在要统计商品总数 请问mysql统计三个表的数据总数该怎么写
SELECT SUM(a) from(SELECT COUNT(*) a FROM 票务商品表
UNION
SELECT COUNT(*)a FROM 抽奖商品表
UNION
SELECT COUNT(*) a FROM 积分兑换表) as aa
select * from (
select a1 from table1
union all
select a1 from table2
union all
select a1 from table3) a
SELECT a.countNum + b.countNum + c.countNum
FROM (
(SELECT COUNT(*) AS countNum FROM table_a) a,
(SELECT COUNT(*) AS countNum FROM table_b) b,
(SELECT COUNT(*) AS countNum FROM table_c) c
)