Hi Gad,

you can already do it with a MERGE... INTO..:

merge into TABLEA as A using (
select * from TABLEB
) as B on (A.ID = B.ID)

when matched then update
set V1 = B.V1,
V2 = B.V2
;;

Here's a working example:

-- Declare test table A
declare global temporary table TABLEA as (
select * from(values(1, 'A', 11), (2, 'B', 22), (3, 'C', 33)) x(ID, V1, V2)
) with data with replace
;;

-- Declare test table B
declare global temporary table TABLEB as (
select * from(values(7, 'X', 77), (2, 'Y', 42), (6, 'C', 66)) x(ID, V1, V2)
) with data with replace
;;

-- Merge values from B into A with a matching ID.
merge into TABLEA as A using (
select * from TABLEB
) as B on (A.ID = B.ID)

when matched then update
set V1 = B.V1,
V2 = B.V2
;;

Tim.




________________________________
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> on behalf of Gad Miron <gadmiron@xxxxxxxxx>
Sent: 13 October 2020 21:48
To: midrange-l@xxxxxxxxxxxxxxxxxx <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: RFE for SQL update from

Hello sages

Does anybody know of an RFE for SQL to enable a from clause in SQL update
statement ?
like the way it's done in MS SQL SERVER TSQL.

update file_A
set file_A.field1 = file_B.field1
from file_A inner join file_B on file_B.key = file_A.key

TIA
Gad
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.