what happens when connect 5v and 12v together

Solution
Neither. The fan will probably blow up. It might be rated for 12V, and if you add another wire, it will spin past max speed.

I dont understand how you would be able to control the fan speed this way.