日期:2014-05-16 浏览次数:20769 次
SELECT COUNT(adverId) visit, adverId, statId developersName, productsName FROM tb_statistic_adver_visit v, (SELECT chid, uid, cpid FROM tb_statistic_stat) s, (SELECT developersName, productsName, developersId,id FROM tb_developers_service WHERE 1=1 GROUP BY developersId ) d WHERE 1=1 AND s.uid=v.statId AND s.cpid=d.developersId GROUP BY adverId
show create table tb_statistic_adver_visit; show create table tb_statistic_stat; show create table tb_developers_service;
------解决方案--------------------
create index idx_v_statId on tb_statistic_adver_visit(statId); create index idx_s_cpid on tb_statistic_stat(cpid); create index idx_d_developersId on tb_developers_service(developersId);
------解决方案--------------------
SELECT
COUNT(adverId) visit,
adverId,
statId
developersName,
productsName
FROM
tb_statistic_adver_visit v,
tb_statistic_stat s
(SELECT
developersName,
productsName,
developersId,id
FROM
tb_developers_service
WHERE
1=1
GROUP BY
developersId ) d
WHERE
1=1
AND s.uid=v.statId
AND s.cpid=d.developersId
GROUP BY
adverId