This question already has an answer here:
One of my friends wants to visit me in Austria. We have made a plan to visit other countries too (Poland, Italy, CZ, SK, etc.). In which consulate should he apply for the Schengen visa? He is going to land in Bratislava, Slovakia. The German consulate is near to him compared to other consulates. Does it matter in which consulate he applies for his visa?