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: A better way of achieving this query?

Re: A better way of achieving this query?

From: Galen Boyer <galendboyer_at_yahoo.com>
Date: 9 Apr 2002 07:20:09 -0500
Message-ID: <usn64vqsw.fsf@rcn.com>


On 8 Apr 2002, urbanlegend_at_ozemail.com.au wrote:
> TableA has a blank field (for Address values) that I want populated
> from the records in TableB.
>
> There is a 1-to-1 relationship on an ID field in each Table.

Why wouldn't the fields in TableA be on TableB?

> All I could think of was something like:
>
> Update TableA x
> Set Address =
> (Select TableB.Address from TableB TableB
> where x.ID = TableB.ID);

You could try

update
(
select address,b_address
from tablea a tableb b
where a.id = b.id
)
set address = b_address;

If you get an error containing the words "key preserved" then you will need to create a unique index on tableb.id.

-- 
Galen deForest Boyer
Sweet dreams and flying machines in pieces on the ground.
Received on Tue Apr 09 2002 - 07:20:09 CDT

Original text of this message

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