left join table1 aaa on aaa.id=ccc.table1_id
left join table2 bbb on bbb.id=ccc.table2_id
where 1=1
应该根据table3 进行联合查询
你上面的是Lefttable1 当然是显示table1里的数据了
代码如下:
SELECT a.trumbnail, b.url, c.url
FROM Goods a, Picture b, Picture c
WHERE a.picture=b.id AND a.picture=c.id
SELECT A.ID,
(SELECT COUNT(*) FROM B WHERE A.ID=B.ID group by id) as "总的"
(SELECT COUNT(*) FROM B WHERE A.ID=B.ID AND B.TYPE='好的' group by id) as "好的",
(SELECT COUNT(*) FROM B WHERE A.ID=B.ID AND B.TYPE='坏的' group by id) as "坏的",
(SELECT COUNT(*) FROM B WHERE A.ID=B.ID AND B.TYPE='好的' group by id)
/
(SELECT COUNT(*) FROM B WHERE A.ID=B.ID group by id) AS "良品率"
(SELECT N1 FROM
(SELECT SUM(C.P1) AS N1,B.ID FROM C JOIN B ON B.ID=C.ID AND B.PID=C.PID AND B. B.TYPE='好的' ) T1 WHERE T1.ID=A.ID) AS"好的B每一个*C的某个属性的总和"
FROM A
,
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)