Answer the question
In order to leave comments, you need to log in
How to calculate sum in SQL query?
It is necessary to insert into table 1 the cost of the goods, which is equal to the sum of the cost of its spare parts.
product id 7 price=300+400+500
product id 6 price=200+300
For each id from table 2, calculate its cost and update it in table 1.
Is it possible to do this with an SQL query without data processing via php, and if so, how ?
Table 1 (data for both goods and spare parts)
id price
1 100
2 200
3 300
4 400
5 500
6 0 - after processing 500
7 0 - after processing 1200
Table 2 (Id of the product and Id of spare parts for it)
id id_zapchast
6 2
6 3
7 3
7 4
7 5
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question