在执行此类查询时,我在从 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;
我想知道是否有任何其他查询方法可以提供更快的响应。谢谢:-)