你可以这样select count(*),'a'from table_aunion allselect count(*),'b'from table_b希望可以帮到你。
有关联性就好select a.id,count(distinct a.id),count(distinct b.id)from a,bwhere a.id=b.idgroup by a.id假设id是关联字段。