Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old June 13th, 2003, 07:51 PM
pegger pegger is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 3 pegger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Oracle Query Question

I have been fumbling with this problem for a while now, hopefully someone will be able to help me out with this.

I am using this following data in my table, Part ID, Reference ID.

The theory is that parts in the PID col work with the parts in the RID col. For example (using row 1-3 data) PID 1 works with RID 2, 3, 4, and thus PID 2 works with RID 6, 9, 10, 5, 7 and PID 5 works with PID 11, 12. So there becomes a tierd relationship between all of the parts. What I would like to accomplish is to select all of the RIDs that work in relation to any PID within 4 tiers of the orginal PID.

A simple example would be that PID 2 would have the following relationships. 9,10,5,6 (direct teir 1) which in turn would relate 11,12 (via 5, teir 2), which in turn would relate 15,16 (via 11 tier 3) and 17 (via 12, tier 3), which would relate 18 (via 17, teir 4)

So far I have only been able to generate a sql statement to select 1 tier at a time, when what I am looking for is a result set containing all of the RIDs within 4 tiers of the orginal PID. That, being said, I belive that I am on the wrong track and in need of a fresh look at the problem and fresh input.


PID RID
---------- ----------
1 2
1 3
1 4
2 6
2 9
2 10
2 5
3 7
3 8
5 11
5 12
11 16
11 15
12 17
13 14
17 18

I hope I have express this in some understandable context. I would appreciate any help or input that anyone can give.

Thanks,

Paul

Reply With Quote
  #2  
Old June 14th, 2003, 08:04 AM
r937's Avatar
r937 r937 is online now
SQL Consultant
Dev Shed God 24th Plane (16500 - 16999 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 16,743 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 2 Days 21 h 15 m 47 sec
Reputation Power: 870
try this:
Code:
select tier1.PID, tier1.RID
     , tier2.PID, tier2.RID
     , tier3.PID, tier3.RID
     , tier4.PID, tier4.RID
  from yourtable tier1
left outer
  join yourtable tier2
    on tier1.RID = tier2.PID
left outer
  join yourtable tier3
    on tier2.RID = tier3.PID
left outer
  join yourtable tier4
    on tier3.RID = tier4.PID
 where tier1.PID = 2

rudy
http://r937.com/

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Oracle Query Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway