I looked it up and we had both exceptions to the rule tonight, the starter not making it 5 innings and the scorer giving the win to the reliever that pitched the most effectively. (While Miller did the best yesterday, Wilson got an out on 2 pitches so it's not like he was ineffective like Mortenson was today, although Mortenson didn't allow a run (thanks to Breslow) so I wouldn't have been upset it Mortenson got the win.
In Major League Baseball, the winning pitcher is defined as the pitcher who last pitched prior to the half-inning when the winning team took the lead for the last time.
There are two exceptions to this rule. The more common exception is that a starting pitcher must complete five innings to earn a win (four innings for a game that lasted five innings on defense). If the starting pitcher fails to meet the innings requirement, the official scorer awards the win to the relief pitcher who, in the official scorer's judgment, was the most effective.
The second exception applies only to a relief pitcher who makes a "brief appearance" and is himself later relieved. If, in the official scorer's judgment, the relief pitcher was "ineffective", the win is awarded to the succeeding relief pitcher who was most effective, in the official scorer's judgment.[1]
In the Major League Baseball All-Star Game, every pitcher is considered a relief pitcher for the purposes of this rule. For example, starting pitcher Matt Cain was awarded the win in the 2012 All-Star Game despite throwing only two innings.[2]