Table Products : TID , cost
Table Parts : PID , TID , quantity已知 PID , 从 表 Parts 中获取 list of TID ,求和 costSum = Sum(cost * quantity)谢谢了
Table Parts : PID , TID , quantity已知 PID , 从 表 Parts 中获取 list of TID ,求和 costSum = Sum(cost * quantity)谢谢了
调试欢乐多
sum(IFNull(products.cost,0)*parts.quantity)
from parts left join products
on parts.tid=products.tid
group by parts.pid
having parts.pid='somepid'