在 MySQL 5.7.13 和 5.7.11 中容忍 SQL 错误(orderby not in distinct,select not in group by)

usr*_*ΛΩΝ 5 mysql syntax group-by distinct mysql-5.7

此问题与以下 2 个 SQL 错误有关(我添加的换行符)

MySql.Data.MySqlClient.MySqlException (0x80004005):
Expression #2 of ORDER BY clause is not in SELECT list, references column 'auitool2014.a.prog' which is not in SELECT list;
this is incompatible with DISTINCT


MySql.Data.MySqlClient.MySqlException (0x80004005): 
Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'H.C51' which is not functionally dependent on columns in GROUP BY clause; 
this is incompatible with sql_mode=only_full_group_by
Run Code Online (Sandbox Code Playgroud)

我的问题很容易描述,即使没有发布原始 SQL。我有一个5.7.11-log在 Windows 上运行的 Mysql服务器,我可以SELECT A,B GROUP BY A并且SELECT DISTINCT A,B ORDER BY C没有任何问题。是的,从 SQL 的角度来看这是错误的

但它有效,客户很高兴。它永远不会被修复,将来会被修复

我们刚刚5.7.13-log使用 Yum 在 Linux 上安装了一个全新的标准 Mysql 。现在所有包含此类错误的查询都会中断。

我环顾四周,似乎Mysql 团队对不正确的GROUP BYs做了一些工作。我试图禁用完整的 group bys,但后来我遇到了明显的问题。

我还尝试从 Windows 框中复制部分 Mysql 配置,但再次返回到这两个问题。

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
Run Code Online (Sandbox Code Playgroud)

我只想知道如何告诉新的 Mysql 5.7.13 的行为与(有问题的?)版本 5.7.11 完全一样。我们将尝试从 Yum 安装确切的 5.7.11,但这可能需要相当长的时间。所以要更清楚:我如何摆脱这两个错误,谦虚地考虑到最终需要修复 SQL 语句

Ric*_*mes 1

不完全是你所说的:

5.7.5 变更日志说

“SELECT DISTINCT col1 ... ORDER BY col2 形式的查询符合 SQL2003 禁止的条件(隐藏 ORDER BY 列与 DISTINCT 组合),但在启用 ONLY_FULL_GROUP_BY SQL 模式时不会被拒绝。”

也许您应该请求 bugs.mysql.com 提供一种违反 SQL2003 的“模式”,因为没有办法获得您想要的东西。