假设现在有三张这样的表,怎么样合并成一张表,急求!?

MySql 码拜 8年前 (2016-02-03) 811次浏览
表一:first
id      grade
1         20
2         19
表二:second
id     grade
1         18
3         19
表三:third
id      grade
1         20
4        17
本人想合并成表四:sum
id     grade
1        58
2        19
3        19
4        17
有什么办法吗?sql语句不精通,求帮助……
解决方案

40

select id,sum(grade)
from(
	select id      ,grade from first
	union all
	select id      ,grade from second
	union all
	select id      ,grade from third
	union all
) t
group by id

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明假设现在有三张这样的表,怎么样合并成一张表,急求!?
喜欢 (0)
[1034331897@qq.com]
分享 (0)