You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 1, if(matches.home > matches.away and countryid = and matches.team1id = teamde' at line 3