Subject Re: [firebird-support] something similar to connect by and prior?
Author Fidel Viegas
On Wed, Apr 8, 2009 at 4:24 PM, Svein Erling Tysvaer
<svein.erling.tysvaer@...> wrote:
> I don't know Oracle syntax, but in Firebird 2.1 or higher you could do
> something like:
>
> WITH RECURSIVE TempTable as (
> SELECT A.ID, cast(0 as Integer) as MyLevel, A.Parent_ID
> FROM MyTable A
> WHERE A.Name = :MyParam
> union all
> SELECT B.ID, TT.MyLevel+1, B.Parent_ID
> FROM MyTable B
> JOIN TempTable TT on B.ID = TT.Parent_ID)
>
> SELECT *
> FROM TempTable
>
> This is just a very rough sketch, naturally you have to transform it
> quite a bit (and if you fail, I'm sure we could help if you tell us an
> example of what you want to achieve).
>

You have become quite good at this, hein? ;D

Fidel.