Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate Fields from Related Tables

Status
Not open for further replies.
Jun 29, 2001
195
US
Hello,

It's been awhile but I need to join 2 tables and pull say Orders from one and Items from the other and concatenate the values. Any idea's?

TIA
ASh~

Ashley L Rickards
SQL DBA
 
well do the tables have a one to one relationship? If not youwill get multiple records withte value from the primary table. But here is the structure

select a.field1 + b.field2 as Test from table1 a join table2.b
on a.ID = b.id

 
As you stated if there are multiple Items I would need to list those also. Here's more detail. Thanks.

ORDERS
ID Customer
1 Company A
2 Company B
3 Company C



ITEMS
ID OID Desc
1 1 Item 1
2 1 Item 2
3 1 Item 3


SELECT ORDERS AND ALL ITS ITEMS


RESULTS:

1, "Company A", "Item 1, Item 2, Item 3"


Concatinate all rows of a sub table.


Ashley L Rickards
SQL DBA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top