Sorry, at cross-purposes there.
GoldCircle is absolutely right that you must look at the rules of the scheme in which you want to earn the miles, to see whether that particular XX "flight" will qualify to earn or not, which may depend on whether it's operated by XX, or by another alliance partner, or a non-alliance partner.
But once you have found that out, it doesn't matter one jot whether the aircraft you are on is also operating "YY" or "ZZ" codes. Because neither YY or ZZ are on your ticket, they don't affect whether or not you earn miles on your "XX" ticket.