文章概览
使用技术:
派生表:在另一个查询(外部查询)中嵌套另一个查询语句(内部查询),并使用内部查询的结果值作为外部查询条件
select sum(score) from (
select count(*) score a from table_01 tb_01
where tb_01.name='姓名'
union all
select count(*) score a from table_02 tb_02
where tb_02.name='姓名'
)as tb
解析 :union all 将多个表 “score” 查询结果 合并=>sum 统计结果集中 “score” 总数 =>tb 派生表名
问题解决
问:Every derived table must have its own alias
每个派生表必须有自己的别名 “tb” 派生表名 不可缺少