Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> SQL Question

SQL Question

From: Bill Mill <bill.mill_at_gmail.com>
Date: 21 Dec 2004 11:47:49 -0800
Message-ID: <1103658469.907129.255490@f14g2000cwb.googlegroups.com>


Hello,

I would like to join two tables sequentially (I don't know the right term for this; I try to explain below). I am a programmer, but inexperienced with sql; I'd appreciate it if someone could help me out.

I have a "schedule" table (which we can assume has already been sorted by the schedule id) with a site id number and a value like:

site_id type

101        A
101        B
101        B
102        C
102        B
102        B
103        A
103        A

and I want to join it with an "objects" table, which has a link to a site, like:

obj_id site_id

1       101
2       102
3       101
4       101
5       102
6       103
7       103

How would I join them such that the first object with site_id of 101 is joined with the type of the first schedule item with site_id of 101, the second object of site 101 with the second schedule item from site 101, etc. in sequential order.

The result I want looks like:

obj_id type site_id

1       A     101
2       C     102
3       B     101
4       B     101
5       B     102
6       A     103
7       A     103

Do I need to use PL/SQL to achieve this? I feel like I don't, but neither can I figure out how to "iterate" through the schedule table without producing repeats. I can think of all kinds of ugly programmatic ways to do it, but I feel like I'm missing an "aha" moment for a SQL solution.
Any help would be appreciated.

Peace
Bill Mill
bill.mill at gmail.com Received on Tue Dec 21 2004 - 13:47:49 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US