ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column — incompatible with sql_mode=only_full_group_by
MySQL rejects a GROUP BY query that selects columns that are neither grouped nor aggregated, because the result for them would be ambiguous.
is not in GROUP BY clause and contains nonaggregated columnincompatible with sql_mode=only_full_group_by Meaning
Since MySQL 5.7 the ONLY_FULL_GROUP_BY mode is on by default. Older queries that relied on MySQL picking an arbitrary row per group now fail, typically after an upgrade or when moving to a new server.
Common causes
- Selected column not in GROUP BY and not aggregated
- Upgrade to MySQL 5.7/8 with the default sql_mode
- ORDER BY or HAVING using a non-grouped column
- ORM generated query without grouping all columns
⚡ Quick fix
- Add the column to GROUP BY or wrap it in
MAX()/ANY_VALUE() - Fix the query logic so each group has one defined value
- As a temporary workaround remove ONLY_FULL_GROUP_BY from sql_mode
Detailed fix by platform
MySQL
SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));(temporary; fix the query instead)
How to diagnose
- Columns — Which ones are neither grouped nor aggregated?
- Mode — SELECT @@sql_mode?
- Source — Upgrade or ORM?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in MySQL
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 2 Dec 2026