3 ms·
MySQL allows the query, but the non aggregate fields are selected randomly
by paulddraper 3y ago
MySQL allows the query, but the non aggregate fields are selected randomly
- wongarsu 3y agoFollowing MySQL's longstanding tradition of just doing whatever instead of showing an error message, no matter how unreasonable the result.
- paulddraper 3y agoMySQL + PHP, name a more iconic match
- deleted 3y ago[deleted]
- sgarland 3y agoIt only allows that if you’ve set it to do so. The default SQL_MODE variable includes ONLY_FULL_GROUP_BY. However, in their brilliance, AWS RDS defaults to only NO_ENGINE_SUBSTITUTION for SQL_MODE, thus merrily allowing partial aggregates with non-deterministic results. Wheee! https://github.com/awsdocs/amazon-rds-user-guide/issues/160 https://github.com/awsdocs/amazon-rds-user-guide/issues/160
- paulddraper 3y agoPrior to 5.7, MySQL always accepted non-aggregated fields. Version 5.7 introduced ONLY_FULL_GROUP_BY, but since that change broke lots of code that depended on this historical behavior, many people disabled it.
- asddubs 3y agorandomly, but after filtering by the criteria in the WHERE part of the query. This can actually be useful sometimes if all non-aggregate fields contain the same value (though I wouldn't actually rely on it, since whether this is allowed depends on how the database is configured, and it makes it easy to introduce errors by changing the query)