Real World
Real World

Reputation: 1719

mySQL Error near AS

Can anyone help with this? I've just switched web servers and I'm testing everything is working but I'm seeing this error. Any ideas whats wrong with the query? It seemed to be valid on my last host

Critical Error
        A database error has occoured.
        Error Returned mySQL query error: SELECT f.* AS fixtures,
                    team1.teamName AS HomeTeam,
                    team1.tid AS HomeTeamID,
                    team2.teamName AS AwayTeam,
                    team2.tid AS AwayTeamID,
       GROUP_CONCAT(n.extra separator ',') AS scorers,
       GROUP_CONCAT(n.homeEvent separator ',') AS homeEvent,
       GROUP_CONCAT(n.eventType separator ',') AS eventType
    FROM fixtures f
    LEFT JOIN notifications n ON n.fixtureID = f.fid
    LEFT JOIN teams team1 ON team1.tid = f.HomeTeam
    LEFT JOIN teams team2 ON team2.tid = f.AwayTeam
    WHERE f.kickoff > 1403823600 AND f.lid=1
    GROUP BY f.fid
    ORDER BY n.time ASC, f.kickoff ASC

mySQL 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 'AS fixtures, team1.teamName AS HomeTeam, team1.tid AS HomeTeamID, ' at line 1

Upvotes: 0

Views: 140

Answers (2)

Andres SK
Andres SK

Reputation: 10974

I don't know what kind of sql engine did you run on your previous webserver, but this is actually not allowed:

SELECT f.* AS fixtures

You need to specify a column, you can't use the wildcard for casting.

Upvotes: 2

Machavity
Machavity

Reputation: 31614

You can't cast a wildcard like that.. Casting is only for single fields

SELECT f.* AS fixtures

Try something like

SELECT f.fixtures AS fixtures, f.field AS field

etc

Upvotes: 3

Related Questions