update A set A.LEG2 = (select LEGID from B where A.TRANS1 = B.DEPACODE and A.DESTCODE = B.DESTCODE); commit;