我被困了,我有三个表,我想加入,我正在使用以下的SELECT查询,它可以像我希望的那样工作,但问题是它需要很长时间才能加载。我知道原因是因为我有两个正确的连接,是否有一种以不同方式编写此查询的方法?
非常感谢/琳达
$qu = "SELECT PULAGART.D5810 as blager, PULAGER.D1001 as D1001,
PULAGER.D18900 as D18900, PULAGER.D1115 as D1115, PULAGER.D1021 as D1021,
PULAGER.D1081 as D1081, PULAGER.D1031 as D1031, PULAGER.D1124 as D1124, PULAGER.D1154 as D1154, PULAGER.D1159 as D1159, PULAGER.D1040 as D1040
FROM PULAGER
RIGHT JOIN PUPRIREG ON (PULAGER.D1001=PUPRIREG.D25306)
RIGHT JOIN PULAGART ON (PULAGER.D1001=PULAGART.D5801)
WHERE (PUPRIREG.D25301 = 'REA') AND (PULAGART.D5810 = 'BS') AND (PULAGART.D5832 > 0) AND (PULAGER.D1159 <> '' AND PULAGER.D1040 <> '' AND
(PULAGER.D1115 NOT LIKE 'SP%') AND PULAGER.D1082 = 'www') AND (".$varugrupper.") ORDER BY $orderby";
答案 0 :(得分:0)
您的查询很好,我建议使用索引快速进行查询响应。
您应该阅读查询优化,以及如何提高查询性能。
以下是一些教程,可以告诉您如何减少查询响应时间。
阅读以下内容: