ahmed naguib
ahmed naguib

Reputation: 145

concat multiple record in one column

I have three tables:

1-

employee(emp_id,emp_name) values(1,"ahmed mohamed")

2-

attach_emp(emp_id [f.k] ,attach_id[f.k]) junction table

values(1,1)
values(1,2) 

3-

attachment(attach_id,attachname)

values(1,"a")
values(2,"b") 

I want the result to be:

emp_id   emp_name        Attachment
1        ahmed mohamed   a,b 

How do I do this join and concatenation between records?

Upvotes: 0

Views: 197

Answers (1)

Stuart Golodetz
Stuart Golodetz

Reputation: 20656

There's a fairly decent-looking article on this here that might be of some use:

http://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/

In particular, the section entitled "Concatenating values when the number of items is not known" looks relevant, for what it's worth.

Upvotes: 1

Related Questions