I have to Tables sale and stock
sale
idStock
1000
1000
1001
1002
1002
1003
stock
idStock sold
1000 0
1001 0
1002 0
1003 0
how to update stock table like this (count total sale items and update the sold column in stock)
idStock sold
1000 2
1001 1
1002 2
1003 1