473,503 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get the complete list of child tables and their child tables and so on...

Suppose I have the following scheam (parent->child) :
A->B->C->D, E->F

Can someone help me with the sql query in db2 which will give me the
complete chain once i give it the parent table. eg. for input A, i
should get B, C, D and for input E it should give me F.

Thanks

May 30 '07 #1
3 2085
am***********@gmail.com wrote:
Suppose I have the following scheam (parent->child) :
A->B->C->D, E->F

Can someone help me with the sql query in db2 which will give me the
complete chain once i give it the parent table. eg. for input A, i
should get B, C, D and for input E it should give me F.
You need to write a recursive query over SYSCAT.REFERENCES.

Enjoy
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 30 '07 #2
On May 30, 5:32 pm, Serge Rielau <srie...@ca.ibm.comwrote:
amitabh.me...@gmail.com wrote:
Suppose I have the following scheam (parent->child) :
A->B->C->D, E->F
Can someone help me with the sql query in db2 which will give me the
complete chain once i give it the parent table. eg. for input A, i
should get B, C, D and for input E it should give me F.

You need to write a recursive query over SYSCAT.REFERENCES.

Enjoy
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Can someone help me formulate this query?

May 30 '07 #3
am***********@gmail.com wrote:
On May 30, 5:32 pm, Serge Rielau <srie...@ca.ibm.comwrote:
>amitabh.me...@gmail.com wrote:
>>Suppose I have the following scheam (parent->child) :
A->B->C->D, E->F
Can someone help me with the sql query in db2 which will give me the
complete chain once i give it the parent table. eg. for input A, i
should get B, C, D and for input E it should give me F.
You need to write a recursive query over SYSCAT.REFERENCES.
Can someone help me formulate this query?
Download my "SQL on Fire" talk from here:
http://www.iiug.org/waiug/present/Fo...Forum2006.html
It explains recursion and has an example.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 30 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
19737
by: maricel | last post by:
Is there a way to list (using db2 command or catalogs) to list hierarchy of table parent & child relationship: 1) A list that shows which table should be deleted first,second,third... 2) A list...
5
4317
by: Ilan Sebba | last post by:
When it comes to adding records in related tables, Access is really smart. But when I try to do the same using ADO, I am really stupid. Say I have two parent tables (eg Course, Student) and one...
1
2844
by: Bartje | last post by:
Hey, I am wondering what the best solution will be to program the following problem in access, the dutch 97 edition. I am developing a database for a day care centre (for my girlfriend). This...
7
1992
by: Neo Geshel | last post by:
Greetings. I have a serious problem. I have multiple sets of tables, several of which are chained more than two tables deep. That is, I have a parent, a child, and a great-grandchild table. ...
5
3517
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
1
2697
by: Dave | last post by:
Hi all, My question is: How do you obtain a complete list of all the users that are registered on the local machine? I've been trying for hours now and can't find anything that will help on...
1
1583
by: sparks | last post by:
I have a main table with teacher names and students I can put this in a subform and filter by teacher name so I have a list of her students in a sub form. the problem I have is this is created in...
8
5959
by: Rick | last post by:
VS 2005 I' m setting up a parent/child datagridviews in a form. I am doing a lot of this by hand coding in order to get the feel of things. I want a change in the parent table to trigger a...
5
2164
by: shapper | last post by:
Hello, I have the following list: <ul id="parent" class="parent"> <li> <img... </li> <ul id="child" class="child"> <li>Message 1</li>
0
7198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7271
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5570
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.