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: Oracle SQL - UPDATE using complex join

Re: Oracle SQL - UPDATE using complex join

From: Daniel Morgan <dmorgan_at_exesolutions.com>
Date: Tue, 08 Oct 2002 23:00:57 GMT
Message-ID: <3DA36389.2E8C0605@exesolutions.com>


JD Uhler wrote:

> Here is my scenario. I would like to UPDATE data in table APPLE, but
> the UPDATE needs criteria from tables PRODUCER and FARM.
>
> I don't want to update all GREEN ORGANIC apples bushels on the all of
> SHINY APPLE's farms (SMITH FARM, JOHNSON FARM, etc.). I only want to
> update the bushels of apples on the JONES FARM.
>
> Pseudeocode:
>
> UPDATE APPLE
> SET BUSHEL_PRICE='5.20', WEIGHT='10.5'
> WHERE
> COLOR='GREEN' AND
> TYPE='ORGANIC' AND
> PRODUCER.NAME='SHINY APPLE COMPANY' AND
> FARM.LOCATION='JONES FARM'
>
> JOIN: PRODUCER.NAME=APPLE.NAME
> JOIN: PRODUCER.LOCATION=FARM.LOCATION
>
> Changing the data structure is not a possibility at this time.
>
> What SQL statement do I use?
>
> Thank you
>
> JD

Update some_table
SET (field1, field2, field3) =

   SELECT (field1, field2, field3)
   FROM table1, table2
  WHERE table1.field = table2.field;

Daniel Morgan Received on Tue Oct 08 2002 - 18:00:57 CDT

Original text of this message

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