qq_笑_17
数据我这里叫a,b,c了,跟你表1,2,3是对应的123456789101112131415161718create table a(uid int,name varchar(10))insert into a values (1,'张一')insert into a values (2,'张二') create table b (uid int,type1 varchar(1))insert into b values (1,'a')insert into b values (1,'b')insert into b values (1,'c')insert into b values (2,'b')insert into b values (2,'c') create table c(uid int,type2 varchar(1))insert into c values (1,'a')insert into c values (2,'b')insert into c values (2,'c')运行12345select t1.uid,t2.c1,t3.c2 from a t1left join (select uid,count(*) c1 from b group by uid) t2 on t1.uid=t2.uidleft join (select uid,count(*) c2 from c group by uid) t3 on t1.uid=t3.uid 结果