Q:

Count who scored more goals per match

I'm trying to compare two soccer players who played in the same team and I'm trying to know who scored more goals in each game they played together and COUNT the number of times a player scored more goals than the other in each game.  For example:

Game 1: Messi 2 goals - Neymar 0 goals
Game 2: Messi 2 goals - Neymar 3 goals
Game 3: Messi 4 goals - Neymar 1 goal

The final result should be Messi = 2 , because he scored more goals in 2 games. 
I have the next query to find the players who share the same team and game with my chosen player (Messi in this example):
SELECT S1.Team, S1.Game, S1.Player, S2.Team, S2.Game, S2.Player 
FROM Mytable S1 
INNER JOIN Mytable S2 ON S1.Team = S2.Team AND 
S1.Game= S2.Game AND 
S1.Player LIKE '".mysql_real_escape_string($Messiinthiscase)."'  
AND S2.Player <> '".mysql_real_escape_string($Messiinthiscase)."'; 

Mytable is like:
Player | Team | Game | Goals
-------------------------------
Messi      A      G1     2
Neymar     A      G1     0
Messi      A      G2     2
Neymar     A      G2     3
Messi      A      G3     4
Neymar     A      G3     1

but I don't know how to implement a COUNT to compare both players.  Probably it is a stupid question with an easy answer but I've been hours working on it and nothing comes to my mind. 
Thanks for all your help

A:

Although a strange query in itself, lets see if this helps.   You are on a good track, and as you stated, it is another TEAM-MATE who PLAYED IN the same game...  So you need a SUM() based on a case/when grouped by your "Messi" player and whoever else played and scored... THEN apply a HAVING.   So, if Messi had 5 team-mates, there should be 4 possible returns
Messi vs Team-mate 1
Messi vs Team-mate 2
Messi vs Team-mate 3
Messi vs Team-mate 4
and of those, Messi may have scored more than team-mates 1, 2 and 4, but less than 3. 
SELECT
      S1.Team, 
      S1.Player, 
      S2.Player,
      sum( case when s1.goals > s2.goals then 1 else 0 end ) as Player1Higher,
      sum( case when s1.goals < s2.goals then 1 else 0 end ) as Player1Lower
   FROM 
      Mytable S1 
         INNER JOIN Mytable S2
            ON S1.Team = S2.Team 
           AND S1.Game = S2.Game 
           AND NOT S1.Player = S2.Player
   WHERE
      S1.Player LIKE '".mysql_real_escape_string($Messiinthiscase)."' 
   GROUP BY
      S1.Team,
      S1.Player,
      S2.Player
   HAVING 
      sum( case when s1.goals > s2.goals then 1 else 0 end ) >
      sum( case when s1.goals < s2.goals then 1 else 0 end ) 

Notice the WHERE clause has your criteria for "Messi" string, and the JOIN clause just says player 1 (Messi) IS NOT the same for player 2. 
The group by is NOT including the EACH GAME as you want the total based on games that the players both played in...
Finally the having includes the final "keep only these records" where the sum of player 1 goals exceeds the sum of player 2 goals. 
If you remove the HAVING clause, you would see your results that Messi had 2 games higher goals and 1 game LESS goals compared to player Neymar
The comparisons do NOT consider "=" as neither player had MORE points than the other... so if such a game where BOTH people scored 2 points, then neither would be considered the higher scoring player. 
The comparison could be simplified even more by doing
  sum( case when s1.goals = s2.goals then 0
            when s1.goals > s2.goals then 1 else -1 end ) as NetGames

So, again, if the score is tied, then nobody is better.   If s1 goals are higher, +1, otherwise the other player was higher, -1.   If the Net Games is positive, then player 1 was better player, = 0 tie, negative is other player better.