M
Muppet
I have 2 tables:
-- Table1 -------------
Color Price Height
-----------------------
Green 1 10
Red 2 20
Orange 3 30
-- Table2 -------------
Color Length Width
-----------------------
Blue 100 1000
Red 200 2000
Green 300 3000
I want to 'merge' values joined on Color. The values need to be
merged based on color and the Amounts need to be in separate columns. The
final result should look like:
Color Price Height Length Width
--------------------------------------
Green 1 10 300 3000
Red 2 20 200 2000
Orange 3 30
Blue 100 1000
Some things can be depended on:
- Table1 might have colors that are not in Table2 and vice versa.
- Colors within a table will never be duplicated (although both tables may
contain the same colors).
- The only common field is Colors.
I have been able to get as far as the first query to merge Table2 contents
with Table1:
SELECT Tbl1.*, Tbl2.Length, Tbl2.Width
FROM Tbl1 LEFT JOIN Tbl2 ON Tbl1.Color = Tbl2.Color;
but then I'm stuck.
Thanks for any suggestions.
-- Table1 -------------
Color Price Height
-----------------------
Green 1 10
Red 2 20
Orange 3 30
-- Table2 -------------
Color Length Width
-----------------------
Blue 100 1000
Red 200 2000
Green 300 3000
I want to 'merge' values joined on Color. The values need to be
merged based on color and the Amounts need to be in separate columns. The
final result should look like:
Color Price Height Length Width
--------------------------------------
Green 1 10 300 3000
Red 2 20 200 2000
Orange 3 30
Blue 100 1000
Some things can be depended on:
- Table1 might have colors that are not in Table2 and vice versa.
- Colors within a table will never be duplicated (although both tables may
contain the same colors).
- The only common field is Colors.
I have been able to get as far as the first query to merge Table2 contents
with Table1:
SELECT Tbl1.*, Tbl2.Length, Tbl2.Width
FROM Tbl1 LEFT JOIN Tbl2 ON Tbl1.Color = Tbl2.Color;
but then I'm stuck.
Thanks for any suggestions.