Link to home
Start Free TrialLog in
Avatar of liltyga
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!
Avatar of FarWest
FarWest

I think the best way to do that is using a function that utilize a cursor to build the list of values string
Avatar of liltyga

ASKER

how would you do that?
ASKER CERTIFIED SOLUTION
Avatar of siavashgh
siavashgh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of liltyga

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.
Avatar of NerdsOfTech
Can you give an example of data and the "desired output" of the data?

Thanks!
Avatar of liltyga

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.