这个 idea 是对几个表进行求和.我可以让COUNT
起作用,但当我将其更改为SUM
时,我会得到一个错误.
查询错误:ERROR:ER_PARSE_ERROR:您的SQL语法中有一个错误;请查看与您的MySQL服务器版本对应的手册,以了解要在‘*)FROM(SELECT*FROM T1 UNION SELECT*FROM T2 UNION SELECT*FROM T3)a’第1行使用的正确语法
create table t1(s int);
create table t2(s int);
create table t3(s int);
insert into t1 values(1);
insert into t2 values(2);
insert into t3 values(3);
select count(*) from
(select * from t1 union
select * from t2 union
select * from t3
) as ta;