关于EXISTS的牛刀小试

1.将B表中不存在于A表中的记录插入A表中:

INSERT INTOA
SELECT FIELD1,FIELD2
FROMB
WHERE NOT EXISTS
(
SELECT * FROMA
WHERE B.ID =A.ID AND OTHERS CONDITION);

2.仅更新A表中满足与B表相关的记录

UPDATEA
SETFIELD1 = FIELD1_VALUE
WHERE EXISTS (
SELECT * FROMA
WHERE B.ID = A.ID AND OTHERS CONDITION ) ;

你可能感兴趣的:(exists)