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