Subject Re: Concatenate field from multiple records
Author Adam
--- In firebird-support@yahoogroups.com, "nikicab_1999"
<nikicab_1999@y...> wrote:
> I appreciate any hint or help with this issue:
>
> I have Groups (of categories) table and Categories table, 1-->many;
> Group_id is foreign key in categories table. I need this result set:
>
> Group_id Groupname Categories
> 1 Name1 Cat1;Cat2;cat5
> 2 Name2 Cat6;Cat8...
>
> i.e. I want to have just one result field from Category in the form
> similar to TStringList.CommaText. Result set will be used in other
> JOIN statements.
>
> I am thinking about stored proc with cursor but cannot make
anything...
> Thanks,
> Nick

Nick, a stored procedure could be made, something like the following
pseudo code

make descr a varchar(some big number)

for select id, name from groups into :id, :name do
begin
descr = '';
for select name from category into :cat do
begin
descr = descr || ';' || :cat;
end
-- remove the first ;
suspend;
end

Of course if you are planning on using these values in some
condition, you know about the number of members inside an IN
statement unless I misunderstand you.

Adam