2 回答
TA贡献2051条经验 获得超10个赞
数据
我这里叫a,b,c了,跟你表1,2,3是对应的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | create 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') |
运行
1 2 3 4 5 | select t1.uid,t2.c1,t3.c2 from a t1 left join (select uid,count(*) c1 from b group by uid) t2 on t1.uid=t2.uid left join (select uid,count(*) c2 from c group by uid) t3 on t1.uid=t3.uid |
结果
- 2 回答
- 0 关注
- 583 浏览
添加回答
举报