Advertisement
Guest User

Untitled

a guest
Jul 8th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. SELECT m.id, m.round_id, m.datetime,
  2. CASE m.status
  3. WHEN 1 THEN 'scheduled'
  4. WHEN 2 THEN 'postponed'
  5. WHEN 3 THEN 'canceled'
  6. WHEN 4 THEN 'playing'
  7. WHEN 5 THEN 'finished'
  8. END AS match_status,
  9. m.gameweek, m.home_team_id, m.home_team_half_time_score, m.home_team_score,
  10. m.home_extra_time, m.home_penalties, m.away_team_id, m.away_team_half_time_score,
  11. m.away_team_score, m.away_extra_time, m.away_penalties, m.venue_id,
  12. m.venue_attendance, m.aggregate_match_id,
  13. t.name AS home_team_name,
  14. t_info.shield_link AS home_team_shield,
  15. t2.name AS away_team_name,
  16. t2_info.shield_link AS away_team_shield,
  17. c.name AS competition_name,
  18. c.id AS competition_id,
  19. r.name AS round_name
  20. FROM `match` m
  21. LEFT JOIN team t ON m.home_team_id = t.id
  22. LEFT JOIN team_info t_info ON t.id = t_info.team_id
  23. LEFT JOIN team t2 ON m.away_team_id = t2.id
  24. LEFT JOIN team_info t2_info ON t2.id = t2_info.team_id
  25. LEFT JOIN competition_rounds r ON m.round_id = r.id
  26. LEFT JOIN competition_seasons s ON r.season_id = s.id
  27. LEFT JOIN competition c ON c.id = s.competition_id
  28. WHERE 1 AND m.status IN (1, 2, 3, 4, 5) AND m.round_id IN (:round_id1) AND m.gameweek = (SELECT m2.gameweek
  29. FROM `match` m2
  30. ORDER BY (status < 5) DESC,
  31. (CASE WHEN status < 5 THEN gameweek END) ASC,
  32. gameweek DESC
  33. LIMIT 1
  34. ) ORDER BY m.datetime DESC LIMIT 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement