Searching a function to get the rotation of one Vector3 in relation to another

I need it to get the rotation of a 3rd Person Camera in relation to its target. If the rotation around the X axis is near to 90 degrees, the camera will be stopped rotating upwards (and the other way around with -90 degrees).