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: Update field from field in different table

Re: Update field from field in different table

From: <tkirwan1679_at_my-deja.com>
Date: Thu, 08 Jul 1999 09:33:47 GMT
Message-ID: <7m1r9r$6pn$1@nnrp1.deja.com>


In article <3769124b.1372080261_at_news1-alterdial.uu.net>,   mred_at_qconline.com wrote:
> I have to update the vendor_name field in table A with values from the
> vendor_name field from table B, where the vendor_id fields from each
> table match.
> Something like:
> update tableA
> set tableA.vendor_name =
> tableB.vendor_name
> where tableA.vendor_id = tableB.vendor_id
> But this doesn't work. It returns an error saying tableB.vendor_id is
> an invalid field. What am I doing wrong? My guess is that this can't
> be done in SQL and I will have to use PL/SQL. Any syntax in either
> case would be greatly appreciated!
>

Have you tried using a single row sub-query in the SET statement? For example :

   update tableA
   set tableA.vendor_name =

       (select tableB.vendor_name
        from tableB
        where tableB.vendor_id = tableA.vendor_id);

The select statement must return only 1 row.

Regards
Tony

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Thu Jul 08 1999 - 04:33:47 CDT

Original text of this message

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