Hello I have this problem and can't find a solution: I have 4 tables with same structure for example as follows:
- Table 1: Result
- Table 2: Store 1
- Table 3: Store 2
-
Table 4: Store 3
- Tables fields: ID - Code - Name - Value
I need a query to read the "Value" for each specific record from tables (Store 1 - Store 2 - Store 3) and calculate the average and save it in table (Result)... and go on for the next record until it's done.
Note: I'm using PHP and MySQL...
Thanks in advanced...
SELECT
result.id,
result.`code`,
result.`name`,
result.value,
term1.value,
term2.value,
term3.value
FROM result
INNER JOIN store1 ON result.`code` = store1.`code`
INNER JOIN store2 ON result.`code` = store2.`code`
INNER JOIN store3 ON result.`code` = store3.`code`
WHERE result.`code` = 123456
ORDER BY result.serial ASC