views:

54

answers:

2

I'm selecting columns from one table and would like to select all values of a column from a related table when the two tables have a matching value, separate them by commas, and display them in a single column with my results from table one.

I'm fairly new to this and apologize ahead of time if I'm not wording it correctly.

+1  A: 

It sounds like what you're trying to do is to take multiple rows and aggregate them into a single row by concatenating string values from one or more columns. Yes?

If that's the case, I can tell you that it's a more difficult problem than it seems if you want to do it using portable SQL - especially if you don't know ahead of time how many items you may get.

The Oracle-specific solution often used in such cases is to implement a custom aggregate function - STRAGG(). Here's a link to an article that describes exactly how to do so and has examples of it's usage.

If you're on Oracle 9i or later and are willing to live with using undocumented functions (that could change in the future), you can also look at the WM_CONCAT() function - which does much the same thing.

LBushkin
WM_CONCAT() did the trick! Thanks for the help and sorry for wordage in the question. It's the shortcomings of a novice!
hsatterwhite
+1  A: 

You want a row aggregation or concatenation function, choices are:

vls