ERROR: 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 'order by TR.ShirtNumber, P.LastName' at line 12 SELECT T.TeamName, S.*, P.*, TR.ShirtNumber, (select D.Name from Leagues L, Divisions D where L.DivisionID = D.DivisionID and L.TeamID = T.TeamID and D.SeasonID = 2018 order by D.DivisionID limit 1) DivisionName FROM Teams T, TeamRosters TR, Players P, Seasons S where TR.TeamID = T.TeamID and P.PlayerID = TR.PlayerID and TR.IsActive = 1 and TR.SeasonID = 2018 and S.SeasonID = 2018 and T.TeamID = order by TR.ShirtNumber, P.LastName