Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SubSelect?
Darel Finkbeiner wrote:
> Disclaimer - I've never used sub selects. I'm not even that familiar
> with Oracle.
>
> I have this situation:
>
> Table A
> primary_id
> data1
> data2
> score_number
>
> Table B
> start_number
> end_number
> threshold_number
>
> I want to select everything from table A and the threshold_number from
> table B where the primary_id is between start_number and end_number.
>
> I can't seem to wrap my head around how to do this. Conceptually I'm
> thinking like this:
>
> select A.primary_id, A.data1, A.data2, A.score_number, (select
> B.threshold_number from B where A.primary_id between B.start_number
> and B.end_number) from A
>
> Any help or pointers would be appreciated.
You are not going to be able to do this unless you are willing to learn some new tricks. And I'm not inclined to write the solution as it looks like homework.
Look at the syntax for subqueries and BETWEEN operator.
You will find demos in Morgan's Library at www.psoug.org under OPERATORS: BUILT-IN. Also look at the examples for JOINS.
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.orgReceived on Fri Feb 16 2007 - 10:37:06 CST