Results 1 to 3 of 3
  1. #1
    mtz1406 is offline Member
    Join Date
    Aug 2008
    Location
    Riyadh - Saudi Arabia
    Posts
    15
    Rep Power
    0

    Default OrgCart problem:how retreive all children of a parent

    How my database design:
    Table org_chart(int ID,int ParentID,string name)

    example:
    __________
    1 |0 |A
    2 |0 |B
    3 |1 |C
    4 |2 |D
    5 |1 |E
    6 |3 |F
    ------------

    Hint:the ParentID of A=0 => A has no parent (it is root)

    the Problem1:
    I want to retrieve all children of a specific parent that has id=X.with ONE SQL statment.SO no need to use a recursive function in my program.
    example:all children of A are (C,E,F).

    the Problem2:
    I want to retrieve all parents of a specific child that has id=X.with ONE SQL statment.SO no need to use a recursive function in my program.
    example:all Parent of f are (C,A).

    I want the solution in SQL standard or in MySQL database
    If any have a solution in another database like oracle write it with note about where can we use.

  2. #2
    roots's Avatar
    roots is offline Moderator
    Join Date
    Jan 2008
    Location
    Dallas
    Posts
    293
    Rep Power
    10

    Default

    There is none, you need recursion even for parent.
    dont worry newbie, we got you covered.

  3. #3
    mtz1406 is offline Member
    Join Date
    Aug 2008
    Location
    Riyadh - Saudi Arabia
    Posts
    15
    Rep Power
    0

    Default

    I found this article

    PHP Code:
    webinade.com/
    web-development/
    creating-recursive-sql-calls-for-tables-with-parent-child-relationships
    but i have no success
    please can you explain me why?or can you give me the SQL statment for my example
    note: i am using MySQL 5

    What about recursive TRIGGER?can do it?
    thank you

Similar Threads

  1. Creating an array of children while excluding grandchildren.
    By xcallmejudasx in forum Advanced Java
    Replies: 3
    Last Post: 10-28-2008, 10:40 PM
  2. How to load a directory in JTree with Children(On expansion)
    By aneesahamedaa in forum AWT / Swing
    Replies: 0
    Last Post: 10-13-2008, 01:23 PM
  3. Parent & Child window issues......
    By jithan in forum New To Java
    Replies: 2
    Last Post: 09-20-2008, 09:21 AM
  4. disable parent window
    By ismailsaleh in forum AWT / Swing
    Replies: 1
    Last Post: 01-08-2008, 12:15 AM
  5. Replies: 0
    Last Post: 08-03-2007, 04:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •