|
Posted by Anon on 10/13/53 11:25
Hilarion wrote:
> Anon <Ao@anonc.com> wrote:
>
>> Since putting this online I have come across this code
>> Find all the children of AAA. In order to avoid running forever, stop
>> after four levels.
>>
>> WITH parent (pkey, ckey, lvl) AS
>> (SELECT DISTINCT
>> pkey
>> ,pkey
>> ,0
>> FROM trouble
>> WHERE pkey = ’AAA’
>> UNION ALL
>> SELECT C.pkey
>> ,C.ckey
>> ,P.lvl + 1
>> FROM trouble C
>> ,parent P
>> WHERE P.ckey = C.pkey
>> AND P.lvl + 1 < 4
>> )
>> SELECT *
>> FROM parent;
>>
>> However I do not have a lvl attribute and so I fear I would be
>> creating an infinite loop.
>
>
>
> What kind of DBMS (SQL engine) do you use? Where did you get this
> example from? For what database structure it's given?
>
> Hilarion
http://ourworld.compuserve.com/homepages/Graeme_Birchall/DB2V82CK.PDF
Page 305
Hilarion I am looking at your current suggestion. I am using phpMyAdmin
to interface with my database currently, its a MySql engine.
Simon
Navigation:
[Reply to this message]
|