如题: SELECT tc_pdg_file.tc_pdg10,ima_file.ima02,ima_file.ima021 FROM tc_pdg_file,ima_file WHERE ima_file.ima01 IN( SELECT DISTINCT tc_pdj_file.tc_pdj01 FROM (SELECT ima01,'3' tc_pdj02 FROM ima_file WHERE imaacti ='Y' UNION SELECT tc_pdi01 ima01,'1' tc_pdj02 FROM tc_pdi_file WHERE tc_pdiacti ='Y' UNION SELECT bmq01 ima01,'2' tc_pdj02 FROM bmq_file WHERE bmqacti ='Y') ima_file LEFT OUTER JOIN tc_pdj_file ON tc_pdj_file.tc_pdj01 = ima_file.ima01 AND tc_pdj_file.tc_pdj02 = ima_file.tc_pdj02 WHERE ima01 IN (SELECT tc_pdj01 FROM tc_pdj_file WHERE tc_pdj_file.tc_pdj02 = ima_file.tc_pdj02 AND tc_pdj18 like '%${tc_pdj18}%')) AND tc_pdg_file.tc_pdg01 IN( SELECT DISTINCT tc_pdj03 FROM (SELECT ima01,'3' tc_pdj02 FROM ima_file WHERE imaacti ='Y' UNION SELECT tc_pdi01 ima01,'1' tc_pdj02 FROM tc_pdi_file WHERE tc_pdiacti ='Y' UNION SELECT bmq01 ima01,'2' tc_pdj02 FROM bmq_file WHERE bmqacti ='Y') ima_file LEFT OUTER JOIN tc_pdj_file ON tc_pdj_file.tc_pdj01 = ima_file.ima01 AND tc_pdj_file.tc_pdj02 = ima_file.tc_pdj02 WHERE ima01 IN (SELECT tc_pdj01 FROM tc_pdj_file WHERE tc_pdj_file.tc_pdj02 = ima_file.tc_pdj02 AND tc_pdj18 like '%${tc_pdj18}%' ) ) 此sql有点长,该如何优化? 求教,感谢
|