MySQL中两表关联更新:
CREATE TABLE TESTA(A INT,B VARCHAR);
INSERT INTO TESTA VALUES (1,'HAHA');
COMMIT;
CREATE TABLE TESTB(A INT,B VARCHAR);
INSERT INTO TESTB(A) VALUES (1);
COMMIT;
UPDATE TESTB LEFT JOIN TESTA ON TESTA.A = TESTB.A SET TESTB.B = TESTA.B;
达梦中的实现:
MERGE INTO TESTB USING TESTA ON (TESTA.A = TESTB.A)
WHEN MATCHED THEN UPDATE SET TESTB.B = TESTA.B
还可以实现匹配删除,或不匹配插入的功能。