I want to do a couple of mathematical operations using different columns from different tables.
Say I have two tables A & B:
A
Value Size Pack
-----------------------------------------
234567 10 1
234589 20 1
234561 30 2
B
Value Quantity Amount
-----------------------------------------
234567 5 200
234589 10 300
234561 8 150
Now I would like to know how to do the following:
NEWCOLUMN (placed into B table) = Amount / (Size * Pack * Quantity)
and display the result on a new column in table B.
I've tried to left join both tables in order to get all columns into one table but I don't know where to go from there. Also, my PK is indeed value and I suppose I have to add a FK in order for it to work?
This is a sample of what I have so far:
SELECT *
FROM `B`
LEFT JOIN `A`
ON `B`.`Value`=`A`.`Value`
I've tried researching this in multiple websites but couldn't find a definite answer.