ONLY_FULL_GROUP_BY wrong behaviour

You are viewing an old version of this article. View the current version here.

When ONLY_FULL_GROUP_BY is set of course you are not allowed to to specify columns in select statement that are not in the group by. But there is an exception: when grouping by id which is a primary key (i.e. unique by definition) all other columns in the same table are functionally dependent upon it. That’s why the following query does not (should not) raise any error: <code>SELECT id, title, genre FROM films GROUP BY id;</code> This acts as expected in MySql, but in mariaDB raises the famous error nonaggregated incompatible with sql_mode=only_full_group_by. Why this happens? There is NOT any possibility to have 2 or more equal records in the same result set since id is a unique primary key. Is this a mariaDB bug or what?

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.