The indirect exchange interaction between localized Cu spins via mobile O holes is derived from the three-band Anderson lattice model for copper oxides for infinite Hubbard repulsion at Cu sites. By means of two nested canonical transformations, Ruderman-Kittel-Kasuya-Yosida (RKKY) and superexchange interactions are found in the fourth order of the Cu-O hybridization amplitude, where both O bands are consequently taken into account. For nearest neighbours the RKKY coupling and the superexchange integral , which increase with the direct O-O transfer, differ in sign and undergo a sign change upon doping. overcompensates .