Custom querty error after move

I moved my web site to new hosting (php mysql) an pages with custom query are not loading givng an error that contains this.

Syntax error or access violation: 1055 Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column.

I found another topic that explained I couladd this line in the connection file.
$this->pdo->exec("set session sql_mode = ''");

That solution would not work for me. I'm guessing the connection file has changed so I don't know where to alter it?

Please provide the custom query causing this error, so we can help.

There are actually 2 (first is below)
Standings page

It worked before I migrated and I actually migrated to the same company just a new personal account

SELECT teamcon.Driver, teamcon.Hometown, teamcon.seqnumb, SUM(PassResults.finish) AS Wins, COUNT(PassResults.RaceID) AS Races
FROM PassResults
INNER JOIN PassSchedule AS schedcon ON (schedcon.RaceID = PassResults.RaceID) INNER JOIN Teams AS teamcon ON (teamcon.seqnumb = PassResults.TeamLink) 
WHERE PassResults.finish = 1 AND schedcon.season = :P1
GROUP BY teamcon.Driver, teamcon.Hometown
ORDER BY Wins DESC

Try changing your query to:

SELECT 
    teamcon.Driver, 
    teamcon.Hometown, 
    teamcon.seqnumb, 
    SUM(PassResults.finish) AS Wins, 
    COUNT(PassResults.RaceID) AS Races
FROM PassResults
INNER JOIN PassSchedule AS schedcon ON schedcon.RaceID = PassResults.RaceID
INNER JOIN Teams AS teamcon ON teamcon.seqnumb = PassResults.TeamLink
WHERE PassResults.finish = 1 
AND schedcon.season = :P1
GROUP BY teamcon.Driver, teamcon.Hometown, teamcon.seqnumb
ORDER BY Wins DESC;

so that the teamcon.seqnumb is also in the groupby.

1 Like

well that ws easy! wonder what changed? I have some other queries to fix now but thank you!

The configuration on your server :slight_smile:

1 Like

I suspect it is related to your server having "strict mode" set. (Google it for more info)

2 Likes