每张表里面有1000条数据,数据库mysql5.1select sum(po.must_pay_cash)
from erp_product_outcoming po
时间: 0.000ms
select sum(po.must_pay_cash),sum(scd.paid_cash)
from erp_product_outcoming po,erp_sale_collent_detail scd
时间: 3.796msselect po.must_pay_cash,scd.paid_cash
from erp_product_outcoming po,erp_sale_collent_detail scd
时间: 20.719msselect po.must_pay_cash
from erp_product_outcoming po
LEFT JOIN erp_sale_collent_detail scd ON scd.shop_id = po.shop_id and scd.flag=1
时间: 104.515msselect sum(po.must_pay_cash - scd.paid_cash) as notCollectionUpToNow 
from erp_product_outcoming as po, erp_sale_collent_detail as scd 
where scd.flag=1 and po.shop_id=scd.shop_id
时间: 104.515ms
后面这两个就我想要的结果,可是这时间太长了,谁有更好的sql语句吗?先谢谢了!