MERGE INTO
tableName1 t1
USING (SELECT * FROM tableName2 where age >10 ) t2 on t1.id = t2.id
WHEN MATCHED THEN update t1.classId = t2.classId
WHEN NOT MATCHED THEN insert (id,name,age,classId) values (t2.id,t2.name,t2.age,t2.classId);
存在时, 更新; 不存在时, 插入。