Subject | Re: selecting concatenated records |
---|---|
Author | Sergio |
Post date | 2012-01-16T20:39:24Z |
> If you are using Firebird 2.1 or later, then the easiest way is to use aTHANKS Thomas !!! Yes, I use FB 2.5
> recursive common table expression. I hope I got it right, but I think
> you get the idea:
>
> with recursive r(id, original_id, hierarchy) as (
> select
> id
> , original_id
> , 1 as hierarchy
> from region
> where id = 1
> union all
> select
> r2.id
> , r2.original_id
> , r.hierarchy + 1
> from region r2, r
> where r.id = r2.original_id
> )
> select * from r;
May I ask you a very big favor? I'd like to undestand how recursive selects are constructed. Could you explaing me a bit the select you made? Or probably there's somewhere in the net a paper about recursion in FB?? I'd really like to andestand this!! It's a very powerfull tool to use!!!
Thank you very much again for your help. Very apreciated!!
-s