mysql 报错 incompatible with sql_mode=only_full_group_by解决
使用peewee这个ORM翻译sql并查询数据
翻译出来的 sql 如下,可以看到其实比较不规范,group by 里面只有 track_source_id,但是 select 里面却有
parser_name、error_class_name、track_source_id
select
`t1`.`parser_name`,
`t1`.`error_class_name`,
`t1`.`track_source_id`,
COUNT('*') as `task_count`
from
`parse_monitoring_detail` as `t1`
where
(`t1`.`success` = 0)
group by
`t1`.`track_source_id`
order by
`task_count` desc正常情况下,执行上面的 sql 应该报错
SQL 错误 [1055] [42000]: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'crawler2.t1.parser_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
但是实际上却没有,为什么?
因为 peewee 创建连接之后,会先执行 SET sql_mode='PIPES_AS_CONCAT'
具体可看: peewee 创建连接前的前置操作,wireshark 抓包
以上就是mysql 报错 incompatible with sql_mode=only_full_group_by解决的详细内容,更多关于mysql incompatible报错的资料请关注脚本之家其它相关文章!
相关文章
教你如何在windows与linux系统中设置MySQL数据库名、表名大小写敏感
数据库和表名在 Windows 中是大小写不敏感的,而在大多数类型的 Unix/Linux 系统中是大小写敏感的。那么我们如何来处理这个问题呢,经过一番查询,发现lower_case_table_names这个参数可以实现大小写敏感,下面我们来详细说明2014-08-08


最新评论