hi need help to subtract quantity from stock .
eg

product

pid prodname
1 Motor
2 cpu

subproduct
sid sname
1 coil
2 switch
3 wire
4 bulb

Mainproduct
mid,pid,pname,sid,sname
1 1 motor 1 coil
2 1 motor 2 switch

stock table

sid,sname,qty
1 coil 100
2 switch 1000
3 wire 50
4 bulb 200




if i sold one item from product then have to minus quantity from stock , product is having sub product . have to reduce quantity for related subproduct

Please help me ,
thanks in advance