Rajesh Karunakaran
Programmer
Dear friends,
Apologies for that ambiguous title but I couldn't write an appropriate one!
I have a table with customer names (unique names). I have another where there are multiple records for same customer name. I am trying to combine these by select names from the first table and the columns from the 1st matching record (on name) from the 2nd table. But my select command mixes up things and gives me as many records as in the 2nd table, ie all records are selected from the 2nd table whereas I want only the values from the first matching record.
table1:
=======
susan
john
thomas
etc...
table2:
======
susan, 22, 2nd street
susan, 22 second street,
john, A/120, St Jean
john, A-120, St.Jean
thomas, 120B, Royal road
thomas, 120-B Royal road,
etc....
Code I tried:
Can you help?
Thanks in advance
Rajesh
Apologies for that ambiguous title but I couldn't write an appropriate one!
I have a table with customer names (unique names). I have another where there are multiple records for same customer name. I am trying to combine these by select names from the first table and the columns from the 1st matching record (on name) from the 2nd table. But my select command mixes up things and gives me as many records as in the 2nd table, ie all records are selected from the 2nd table whereas I want only the values from the first matching record.
table1:
=======
susan
john
thomas
etc...
table2:
======
susan, 22, 2nd street
susan, 22 second street,
john, A/120, St Jean
john, A-120, St.Jean
thomas, 120B, Royal road
thomas, 120-B Royal road,
etc....
Code I tried:
Code:
SELECT table1.name, table2.add1, table2.add2 FROM table1 LEFT OUTER JOIN table2 ON table1.name == table2.name
Can you help?
Thanks in advance
Rajesh