liltyga
asked on
Return Multiple Values in SQL Subquery
Hi,
I want to be able to return multiple values in a subquery, preferably in a comma delimited list. I am using PostgreSQL and ColdFusion. Is there a simple way to accomplish this?
For example, I want something like:
SELECT t.id, t.val2, t.val3,
(SELECT s.id FROM state s WHERE t.id = s.id) as arrayOfStates
FROM table t
Any input would be greatly appreciated!
I want to be able to return multiple values in a subquery, preferably in a comma delimited list. I am using PostgreSQL and ColdFusion. Is there a simple way to accomplish this?
For example, I want something like:
SELECT t.id, t.val2, t.val3,
(SELECT s.id FROM state s WHERE t.id = s.id) as arrayOfStates
FROM table t
Any input would be greatly appreciated!
I think the best way to do that is using a function that utilize a cursor to build the list of values string
ASKER
how would you do that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, but I'm not familiar with creating and returning functions, so I wouldn't even know where to start with regard to writing one to return a comma delimited list of a value; that's why I posted my question here.
Can you give an example of data and the "desired output" of the data?
Thanks!
Thanks!
ASKER
If I were more familiar with the direction given, I probably would have been able to figure out a solution, but I had to go with a workaround.