0
我如何更新此查詢? 我嘗試獲得超過1種產品的所有類別,計算此產品以顯示在她身邊,但我的查詢太慢(2s)。如果可能,我該如何做,但更快?更新PDO查詢的選項
SELECT
C.id, C.name, C.id_dept, C.cat_type, C.num_prod
FROM
(SELECT
C.id, C.name, C.id_dept, C.cat_type,
COALESCE((SELECT count(P.id) FROM Products P WHERE P.status = 1 AND P.promo = 1 AND P.id_cat = C.id), 0) AS num_prod
FROM
Products_Cat C
) C
WHERE
C.num_prod > 0 AND C.cat_type = 1 AND C.id_dept = '{IDD}'
ORDER BY C.name ASC
辛格,我想列出結果並沒有更新數據庫。 – Gus