Home » SQL & PL/SQL » SQL & PL/SQL » Recursive Query (Oracle 10g, WIN XP)
Recursive Query [message #336881] Tue, 29 July 2008 05:06 Go to next message
dev_sri
Messages: 4
Registered: July 2008
Location: Hyderabad
Junior Member
Hi all,

Below is the table design:

select * from child;

REEID PID CID S
----- ---------- ---------- -
1001 101 102 Y
1002 101 103 Y
1003 102 104 N
1004 102 105 N
1005 103 106 N
1006 103 107 Y

6 rows selected.

select * from master;

CID QID RID AID
----- ---------- ---------- ----------
101 20
102 20
103 30

In Master,CID is PK column and in Child CID is the FK Column..

1)Now 101 is PK column in master and FK in child... this record has two child records 102 and 103.
2) 102 record again has child records..104 and 105..

QUESTION: I would like to have query till the leaf node(Last child records) for particular record in parent table(master).

please Help.

Regards,

` sri
Re: Recursive Query [message #336890 is a reply to message #336881] Tue, 29 July 2008 05:20 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
1/ please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Who knows which columns of "master" are filled in your post?
Use the "Preview Message" button to verify.

2/ Always post your Oracle version (4 decimals).

3/ Post a test case: create table and insert statements along with the result you want with these data.

4/ Use CONNECT BY and hierarchical query

Regards
Michel

[Updated on: Tue, 29 July 2008 05:21]

Report message to a moderator

Re: Recursive Query [message #336892 is a reply to message #336890] Tue, 29 July 2008 05:23 Go to previous messageGo to next message
dev_sri
Messages: 4
Registered: July 2008
Location: Hyderabad
Junior Member
Thanks for the inputs...

Could you be more precise in explaining the query.

Regards,
~ sri
Re: Recursive Query [message #336899 is a reply to message #336892] Tue, 29 July 2008 05:29 Go to previous message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Complement on 4/ requires you satisfy 1/, 2/ and 3/

Regards
Michel
Previous Topic: Dependencies
Next Topic: sql update in a loop
Goto Forum:
  


Current Time: Sun Feb 09 09:52:59 CST 2025