Here is the query: SELECT c.CategoryID AS CategoryID, c.Name AS Name, c.Description AS Description, coalesce(b.Blocked, 0) AS Blocked FROM LUM_Category c left join LUM_CategoryRoleBlock crb ON c.CategoryID = crb.CategoryID and crb.RoleID = 4 left join LUM_CategoryBlock b ON c.CategoryID = b.CategoryID and b.UserID = 1 WHERE ( crb.Blocked = '0' or crb.Blocked = 0 or crb.Blocked is null ) GROUP BY c.CategoryID, c.Name, c.Description ORDER BY b.Blocked asc, c.Priority asc;
b.blocked is missing from the GROUP BY clause. The error in triggered only when ONLY_FULL_GROUP_BY is in sql_mode (MySql setting) :SET GLOBAL sql_mode = 'ONLY_FULL_GROUP_BY'