具体语句: UPDATE T_USER A SET A.USER_NAME = (SELECT B.NEW_NAME FROM T_NAME_MAP B WHERE A.USET_ID = B.USER_ID) WHERE EXISTS (SELECT 1 FROM T_NAME_MAP C WHERE A.USER_ID = C.USER_ID );
应该用merge语句(oracle 10g或以上),它是update和insert的组合. MERGE INTO test1 a USING all_objects b ON (a.object_id = b.object_id) WHEN MATCHED THEN UPDATE SET a.status = b.status WHEN NOT MATCHED THEN INSERT (object_id, status) VALUES (b.object_id, b.status);
天生小仙女
2024-10-17 10:33:44
update table1 set (A,B,C)= (select A,B,C from table2)百度地图
风起半山
2024-10-17 11:17:46
update a set c1 = select c2 from b where b.id = a.id