It depends on what you mean by "different". If they are of two different metals such as one is copper and the other is iron, you'll need to use what is called a "dialectric union". It keeps the pipes from being electrically conductive to each other and significantly reduces the corrosion in the pipes. If one pipe is plastic you can just use a plastic fiting that will connect to threaded pipe. It's very common to connect two different pipes together, but to get more specific information you may need to go to a home improvement store and ask for some advice.