How to create a loop query in SQL.

5 pts.
Tags:
SQL
SQL Query
Hello Friends, I am trying to write a SQL code to pull all the parts in a chain. For eg., Part A is replaced by Part B and Part B is replaced by Part C and C to D and so on. Is there anyway that I can pull all the parts in that loop at once. A,B,C,D,....., All these relationships are stored in one table X as below: Part Superseding part A B B C C D D ... ... ... ... ... Please help and Thanks in advance !

Answer Wiki

Thanks. We'll let you know when a new response is added.

You will probably need to create a function to achieve that, but the syntax will be different depending on the database.

What database are you using ?

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Kccrosser
    See this article for a good discussion on the Oracle "connect by" and "start with" syntax, which could possibly give you the solution: http://www.oracle.com/technology/products/oracle9i/daily/oct04.html This lets you chain through records linked like in your data table.
    3,830 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: