1

我被卡住了,我有三个要加入的表,并且我正在使用以下 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";
4

1 回答 1

0

您的查询很好,我建议使用索引来使查询响应快速。

您应该阅读查询优化以及如何提高查询性能。

这里有一些教程将告诉您如何减少查询响应时间。

阅读以下:

  1. 查询的性能提升
  2. 查询优化
  3. 减少查询执行时间
  4. 查询的执行时间
于 2013-04-25T08:49:37.777 回答