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

Home -> Community -> Usenet -> c.d.o.server -> Re: Can I limit the number or records to return given a condition?

Re: Can I limit the number or records to return given a condition?

From: <antonyliu2002_at_yahoo.com>
Date: 14 Sep 2006 13:51:19 -0700
Message-ID: <1158267079.465674.181430@m73g2000cwd.googlegroups.com>


antonyliu2002_at_yahoo.com wrote:
> I need to update one field of T1 from T2. So, I tried this:
>
> update T1 set (MyField) = (select distinct FunField from T2 where
> T1.ID = T2.ID);
>
> T1's ID is a proper subset of T2's ID. In other words, each ID of T1
> has a corresponding record in T2.
>
> But, the problem is that, some IDs in T2 has multiple records, and as a
> result, I get this error:
>
> ORA-01427: single-row subquery returns more than one row
>
> T1 has nearly 7500 records and T2 has nearly 200,000 records. I've
> found some offending IDs from T2.
>
> I am not sure how to handle this problem. Can I somehow limit the
> sub-query to return one and only one record given the condition?
>
> Thanks in advance.

Thanks for those who are considering or have considered helping. This problem has been resolved by using rownum = 1 in the subquery to limit it to return 1 and only 1 record given the condition. Received on Thu Sep 14 2006 - 15:51:19 CDT

Original text of this message

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