如何从 Oracle sql 中的其他 table 更新
How to update from other table in Oracle's sql
我有两个 table,我想从 Oracle sql
中的 Table B 更新 table A
table A
customer_id geo_id geo
1234567890 3521 texas
0987654321 3624 dallas
1597536842 3121 mexicocity
table B
geo_id customer_id
8745 1234567890
2145 0987654321
3699 1597536842
update table A
set geo_id = (select geo_id from table B)
where tableA.customer_id = tableB.customer_id;
使用MERGE
语句
MERGE INTO tablea a
using tableb b ON( a.customer_id = b.customer_id )
WHEN matched THEN
UPDATE SET a.geo_id = b.geo_id
或相关更新
update tablea a set
a.geo_id = (select geo_id from
tableb b
where a.customer_id = b.customer_id)
我有两个 table,我想从 Oracle sql
中的 Table B 更新 table Atable A
customer_id geo_id geo
1234567890 3521 texas
0987654321 3624 dallas
1597536842 3121 mexicocity
table B
geo_id customer_id
8745 1234567890
2145 0987654321
3699 1597536842
update table A
set geo_id = (select geo_id from table B)
where tableA.customer_id = tableB.customer_id;
使用MERGE
语句
MERGE INTO tablea a
using tableb b ON( a.customer_id = b.customer_id )
WHEN matched THEN
UPDATE SET a.geo_id = b.geo_id
或相关更新
update tablea a set
a.geo_id = (select geo_id from
tableb b
where a.customer_id = b.customer_id)