1
我有一定的困難,從MySQL服務器檢索快速響應而進行這樣的查詢:如何提高嵌套mysql查詢速度,如這個?
select distinct(products.id) as product_id,products.title as product_name, (select count(id) from stock where stock.available='0' and stock.product_id=products.id) as none,
(select count(id) from stock where stock.available='1' and stock.product_id=products.id) as available,
(select count(id) from stock where stock.available='2' and stock.product_id=products.id) as staged,
(select count(id) from stock where stock.available='3' and stock.product_id=products.id) as departed,
(select count(id) from stock where stock.available='4' and stock.product_id=products.id) as delivered
from products,stock where products.id=stock.product_id;
我不知道是否有,將提供更快的響應任何其他查詢方法。感謝名單:-)
哦,我的哈姆雷特,這是一個事先聲明我。會第一次使用加入,但是......那邊的那個人做得很好! Thanx隊友:-) – Jeebsion
有錯,請看更新後的版本。 –
啊,是的..再次感謝你哈姆雷特 – Jeebsion