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: