左连接多个表需要太长时间,下面查询。

时间:2018-02-26 11:30:27

标签: mysql sql left-join

SELECT DISTINCT(j.id), 
            j.first_name,
            j.middle_name,
            j.last_name,
            ald.email AS email_address,
            j.photo_file,
            j.unique_id,
            el.title AS education_title, GROUP_CONCAT(DISTINCT(tjt.training_title) SEPARATOR ', ') AS training_title, CONCAT(j.vdc_municipality, ', ', d.district) AS district_name, GROUP_CONCAT(DISTINCT(tms.description) SEPARATOR ', ') AS description
FROM tbl_jobseeker j
LEFT JOIN district d ON j.district=d.district_id
LEFT JOIN zone z ON z.id=d.zone_id
LEFT JOIN tbl_jobseeker_training tjt ON 
                j.id=tjt.jobseeker_id
LEFT JOIN tbl_jobseeker_skill tjs ON 
                j.id=tjs.jobseeker_id
LEFT JOIN tbl_master_skills tms ON 
                tms.id=tjs.skill
LEFT JOIN tbl_jobseeker_education tjee ON 
                tjee.jobseeker_id=j.id
LEFT JOIN tbl_education_level tel ON
                tel.id=tjee.education_degree
LEFT JOIN tbl_jobseeker_employment tje ON
                tje.jobseeker_id=j.id
LEFT JOIN tbl_jobseeker_skilloccupationdetails tjso ON
                tjso.jobseeker_id=j.id
LEFT JOIN tbl_education_level el ON tjso.high_degree=el.id
LEFT JOIN tbl_apply_this_job taj ON taj.jobseeker_id=j.id
LEFT JOIN tbl_vacancydetails tvd ON tvd.id=taj.job_id
LEFT JOIN applicant_login_detail ald ON
                    ald.applicant_id=j.id AND ald.type=1
WHERE j.share_resume=1 AND training_title IS NOT NULL

这个查询需要很长时间才能执行,有没有办法让速度快。执行需要1分钟以上。我花了很多时间来解决这个问题,但我一无所获。

0 个答案:

没有答案