Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
VoidPointer
Starting Member
1 Post |
Posted - 2005-01-15 : 18:04:46
|
| Hi I have a stored procedure which returns data from .. let's say USERS table .Now each user can be in number of departments , and I have connection table - USER_ID - DEPT_ID and departments table of course.I need to show a list of users , and one of the fields in this list is a comma-delimited list of the user departments.now I have something like this :SELECT USER_ID , FIRST_NAME , LAST_NAME FROM USERS;and I have SELECT DEPARTMENTS.DEPARTMENT_NAME FROMUSER_DEPARTMENTS UDINNER JOIN DEPARTMENTS ON UD.DEPT_ID=DEPARTMENTS.DEPT_IDWHERE UD.USER_ID = USERS.USER_IDthe question is how do I combine those , so that the inner select will return me a comma delimited list of department names , and I just return it "AS DEPARTMENT_NAMES" from the main select .Thanks in advance |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
|
|
|
|
|