应该是union all
select username,sum(cnt) as cnt from
(
select username,count(*) as cnt from tbl_name1 group by username
union all
select username,count(*) as cnt from tbl_name2 group by username
......
union all
select username,count(*) as cnt from tbl_name30 group by username
)
group by username
order by cnt desc
或者干脆就
select username,count(*) as cnt from
(
select username from tbl_name1
union all
select username from tbl_name2
......
union all
select username from tbl_name30
)
group by username
order by cnt desc
select username,sum(cnt) as cnt from
(
select username,count(*) as cnt from tbl_name1
union
select username,count(*) as cnt from tbl_name2
......
union
select username,count(*) as cnt from tbl_name30
)
order by cnt desc