Re: SQL: Update .. from .. where ..

From: Mike Kohut, NorthwesTel <mkohutnw_at_yknet.yk.ca>
Date: 1995/06/29
Message-ID: <3st3dm$7n0_at_spot.YKnet.yk.ca>#1/1


yliang_at_charon.rutgers.edu (Yin Liang) wrote:
> Hi, I am whether I can update a field in one table from valuse in another
> table using a simple SQL Statement ?
> ...and I think the Update statement should be:
> Update T1 set T1.Value = T2.Value
> From T1, T2
> where T1.Code = T2.Code (Runs perfect in SYBASE !)

Try this in ORACLE:

Update T1 set Value =
(select T2.Value
 From T2
 where T1.Code = T2.Code)

I used to work for a company that used Oracle, now I work for one that uses Ingres. The example that you gave for Sybase is the same for Ingres as well. I like Oracle's approach better because it is very useful to be able to update from a sub-query. Because Ingres only lets you update one table "from" another table, there are some situations where I have to write extra code to construct temporary tables, in order to accomplish what Oracle can do in one statement. Received on Thu Jun 29 1995 - 00:00:00 CEST

Original text of this message