# 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

**Code:** `1055` · **Category:** MySQL · **Seen on:** MySQL

MySQL rejects a GROUP BY query that selects columns that are neither grouped nor aggregated, because the result for them would be ambiguous.

## 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

1. Add the column to GROUP BY or wrap it in `MAX()`/`ANY_VALUE()`
2. Fix the query logic so each group has one defined value
3. As a temporary workaround remove ONLY_FULL_GROUP_BY from sql_mode

## Detailed fix by platform

### MySQL

1. `SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));` (temporary; fix the query instead)

## How to diagnose

1. **Columns** — Which ones are neither grouped nor aggregated?
2. **Mode** — SELECT @@sql_mode?
3. **Source** — Upgrade or ORM?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/mysql/1055-only-full-group-by)
