Re: Update and from

From: Sanjay Sundaram <sanjay_at_adjs09.abu-dhabi.geoquest.slb.com>
Date: 19 Jan 1994 11:15:10 GMT
Message-ID: <2hj4nu$bi3_at_snlsu1.london.sinet.slb.com>


In article 4zJ_at_netcom.com, jdennis_at_netcom.com (John Dennis) writes:
>
> I'm a Sybase person out of his element. I'm trying to update a
> table where the same key exists in another, identical table. Not
> to push Sybase in this town but it does allow the "FROM" clause in
> an UPDATE. For example, I have two tables, TABLE1 and TABLE2 which
> have the columns KEY, A and B. Now I want to put TABLE1's A and B
> values into TABLE2 WHERE TABLE1.KEY = TABLE2.KEY. It doesn't seem
> obvious how I can do this (in Oracle). In Sybase I'd use:
>
> UPDATE TABLE2
>
> FROM TABLE1 T1,
> TABLE2 T2
> SET T2.A = T1.A,
> T2.B = T1.A
>
> WHERE T1.KEY = T2.KEY
>
> So, Oracle SQL experts, what is the clear (foggy to me) way to do
> this?
>
> Thanks in advance,
> John
>

John,

        Here is what you would do.

	UPDATE TABLE2 
	SET TABLE2.A = TABLE1.A, TABLE2.B = TABLE1.B
	WHERE TABLE1.KEY = TABLE2.KEY;


That will do it.

Sanjay Sundaram
Schlumberger-Geoquest, Abu Dhabi. Received on Wed Jan 19 1994 - 12:15:10 CET

Original text of this message