-
I'd like to be able to return a single cell containing a string formed from all the records in a table, ie
mysql> SELECT OrganisationName FROM t1;
+------------------+
| OrganisationName |
+------------------+
| this |
| that |
| the other |
+------------------+
I want this:
+-----------------------+
| SomeSelectFunction |
+-----------------------+
| this, that, the other |
+-----------------------+
-
Probably will have to use a stored function. Something like:
Code:
declare
lAnswer varchar2(2222);
begin
for x in (select rownum, OrganisationName from t1) loop
if x.rownum = 1 then
lAnswer := x.OrganisationName;
else
lAnswer := lAnswer || ', ' || x.OrganisationName;
end if;
end loop;
return lAnswer;
end;
/
-
No other choice to get it done with a single querry
-
Sure, by using DECODE or CASE, but only if you know in advance how many records there are in a table...