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 -> Re: Nested SQL query involving multiple tables!

Re: Nested SQL query involving multiple tables!

From: sybrandb <sybrandb_at_gmail.com>
Date: 23 Jan 2007 07:19:23 -0800
Message-ID: <1169565563.350723.203100@q2g2000cwa.googlegroups.com>

On Jan 23, 4:12 pm, qazmlp1..._at_rediffmail.com wrote:
> have two tables:
> Table-1, with the columns Col-a1, Col-b1 and some other columns
> Table-2, with the columns Col-a2, Col-b2, Col-c2 and some other
> columns
>
> Here are the tables filled with some sample record values:
>
> Table-1
> =====
> Col-a1 Col-b1
> ------- --------
> 120 true
> 121 true
> 234 false
> 98700 true
>
> Table-2
> =====
> Col-a2 Col-b2 Col-c2
> --------- --------- --------
> 120 10 Val1
> 120 20 Val2
> 121 15 Val1
> 234 35 Val3
> 98700 255 Val3
> 98700 355 Val3
>
> I would like to do the following using the SQL:
> - select the Col-a1 values in the Table-1 where Col-b1=true . For each
> of these, select the records in the Table-2 where there is only one
> association between Col-a2, Col-b2. For those records, set the Col-c2
> value to null.
>
> For the above sample records, only the following record
> 121 15 Val1
> should become
> 121 15 null
>
> What can be the best performant query to achieve this? I tried with
> some queries, but I get errors like "single-row subquery returns more
> than one row". Hence, I require your help.

This is not the place to get a free Oracle course for people who - don't want to read manuals
- don't want to do their own homework.
This is especially not the place to have someone else do your work for free.

PLEASE go away, and find a different playground.

-- 
Sybrand Bakker
Senior Oracle DBA
Received on Tue Jan 23 2007 - 09:19:23 CST

Original text of this message

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