Skip to content

MySQL error code 1055 is a common issue related to the SQL mode ONLY_FULL_GROUP_BY. This error typically occurs when a query involving a GROUP BY clause includes non-aggregated columns that are not functionally dependent on the grouped columns. Understanding and resolving this error involves adjusting query structure or server settings.

Understanding the error code 1055

When you encounter error 1055, MySQL is essentially indicating that your query does not comply with the ONLY_FULL_GROUP_BY SQL mode. This mode is designed to prevent ambiguous query results by ensuring that all selected columns in a GROUP BY clause are either aggregated or functionally dependent on the group.

Common scenarios leading to error 1055

  • Selecting non-aggregated columns that are not part of the GROUP BY clause.
  • Using expressions or functions on grouped columns without aggregation.
  • Joining tables in a way that the grouped column is not unique.

Resolving error 1055

Resolving this error typically involves either modifying the query to comply with the ONLY_FULL_GROUP_BY rules or adjusting the SQL mode settings on the MySQL server.

Modifying the query

Adjust your query to ensure that all selected columns are either part of the GROUP BY clause or are used in an aggregate function like SUM(), COUNT(), MAX(), etc.

SELECT column1, COUNT(column2)
FROM your_table
GROUP BY column1;

Adjusting SQL mode settings

If modifying the query is not feasible, consider changing the SQL mode on the MySQL server by removing ONLY_FULL_GROUP_BY.

SET sql_mode = 'TRADITIONAL';

Using ANY_VALUE() function

As an alternative, you can use the ANY_VALUE() function to bypass the ONLY_FULL_GROUP_BY restriction for specific columns.

SELECT column1, ANY_VALUE(column2)
FROM your_table
GROUP BY column1;

Best practices to avoid error 1055

  • Always ensure that your GROUP BY queries are logically consistent and clear.
  • Regularly review and understand the SQL modes set on your MySQL server.
  • Prefer modifying queries over changing server settings for broader compliance.

Troubleshooting tips

  • Check your query for any non-aggregated columns that are not included in the GROUP BY clause.
  • Review the MySQL server SQL modes to understand the current settings.
  • Use EXPLAIN to analyze and understand how your query is being executed.

During troubleshooting, Basedash helps teams move faster by combining AI-assisted analysis with direct SQL access, so you can validate fixes, monitor results, and share clear dashboards after incidents are resolved.

Conclusion

Understanding and resolving MySQL error code 1055 involves a careful examination of your queries and possibly adjusting your MySQL server settings. By adhering to best practices and using the right tools, you can effectively manage and avoid such errors in your database operations.

Written by

Robert Cooper avatar

Robert Cooper

Senior Engineer at Basedash

Robert Cooper is a senior engineer at Basedash who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.

View full author profile →

Looking for an AI-native BI tool?

Basedash lets you build charts, dashboards, and reports in seconds using all your data.