select *,(select sum(0),sum(1) from table1 where pid=tabel2.pid) from tabel2
报错:Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
怎么可以 查出2个sum的结果放在表后面呢
你用关联查询,select * from table2 a, (select sum(0),sum(1) from table1 ) b where a.id = b.id
select *,(select sum(0) from table1 where pid=tabel2.pid),(select sum(1) from table1 where pid=tabel2.pid) from tabel2
select * from tabel2 left join (select sum(0),sum(1),pid from table1 group by pid) t1 on t1.pid=tabel2.pid
1.不用子查询,使用表关联
2.继续使用子查询,但写两遍,分别取需要的字段