Mysql两个查询结果相加?错误:Every derived table must have its own alias
SELECT username,SUM(ycnum) AS yznum,SUM(zfnum) AS zfnum FROM (select * from tempactive where exists (select * from topic1activeuser where username=tempactive.username) UNION select * from topic1activeuser where exists (select * from tempactive where username=topic1activeuser.username)) GROUP BY username
一直报错Every derived table must have its own alias
提示要给子查询加上别名
SELECT username,SUM(ycnum) AS yznum,SUM(zfnum) AS zfnum FROM (select * from tempactive where exists (select * from topic1activeuser where username=tempactive.username) UNION select * from topic1activeuser where exists (select * from tempactive where username=topic1activeuser.username)) AS total GROUP BY username
select * from tempactive where exists (select * from topic1activeuser where username=tempactive.username)
结果1:
select * from topic1activeuser where exists (select * from tempactive where username=topic1activeuser.username)
结果2:
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇: 2016面试——腾讯、蚂蚁金服、蘑菇街
- 下一篇: 数据挖掘工程师的面试问题与答题思路
