- SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' 1, 0)) AS home_wins, SUM(if(winner_id = , 1, 0)) AS away_wins, SUM(if(winner...' at line 1 (Connection: mysql, SQL: select count(*) as total_matches, SUM(if(winner_id = , 1, 0)) AS home_wins, SUM(if(winner_id = , 1, 0)) AS away_wins, SUM(if(winner_id = AND home_team = , 1, 0)) AS home_team_at_home, SUM(if(winner_id = AND away_team = , 1, 0)) AS home_team_at_away, SUM(if(winner_id = AND home_team = , 1, 0)) AS away_team_at_home, SUM(if(winner_id = AND away_team = , 1, 0)) AS away_team_at_away, SUM(if(ISNULL(winner_id), 1, 0)) AS draws, SUM(CASE WHEN home_team = THEN home_score ELSE away_score END) AS home_goals, SUM(CASE WHEN home_team = THEN home_score ELSE away_score END) AS away_goals from `events` where ((`home_team` is null and `away_team` is null) or (`home_team` is null and `away_team` is null) and `competition_id` is not null) and `events`.`finished` = 1 and `events`.`deleted_at` is null limit 1)