He must pitch a minimum of 5 complete innings.
There is no limit in regards to how many innings a Starting Pitcher must pitch in the Major League Baseball All Star game, a team can be winning and the Starting Pitcher could pitch only 2 innings but because All Star games have different rules, they can be given the Win.
In a Major League Baseball game, Starting Pitchers can pitch as many innings as needed, it is up to the discretion of his Manager however Starting Pitchers must pitch 5 innings in order to qualify for a win.
A starting pitcher needs to pitch at least 5 innings to get the win. Any subsequent pitcher can get the win even if he only retires one batter (or base runner). If the starting pitcher leaves with the lead but without pitching 5 innings, and his team maintains that lead, the official scorer can decide which pitcher to give the win to.
Four consecutive innings if she is the starting pitcher. There's no minimum number required for relief pitchers.
As many as he can in a game before his couch takes him out