Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jung1975
Aged Yak Warrior
503 Posts |
Posted - 2004-06-24 : 12:09:31
|
I have two tables: organization and Organization_RelationshipOrganization table has a unique Org_id Org_id Org_name Org_address100729 100731 100732 100733 100734 100735 100759 100761 100762 100730 100760 Organization relationship table shows the relationship between Org_id and it’s hierarchy. Orginization relationship Org_id Org_rel100729 100730100729 100731100729 100735100729 100759100731 100732100731 100733100731 100734100735 100736100759 100760There is a foreign key ( Org_id) relationship between two tables.I would like to return the result that looks like:Parent_org Sub_org1 Sub-org2100729 100729 100729100729 100730 100730100729 100731 100731100729 100731 100732100729 100731 100733100729 100731 100734100729 100735 100736100729 100759 100760 The logic here is:1)Org_id 100729 itself can be both sub_org1 and sub_org2 because it’s a parent location (location level 1).2)Org_id 100729 has 100730,100731,100735 and 100759 as Sub_org1 3)Org_id 100731 has 100732,100733 and 100734 as Sub_org24)Org_id 100735 is a child_location of 100729(parent_location) and parent_location of 100736(Sub_org2) |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-06-24 : 12:30:49
|
| Please post DDL and DML. CREATE TABLE and INSERT INTO (for sample data) statements.Tara |
 |
|
|
|
|
|