欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mysql 報(bào)錯(cuò) incompatible with sql_mode=only_full_group_by解決

 更新時(shí)間:2023年10月19日 11:51:30   作者:ponponon  
這篇文章主要為大家介紹了mysql 報(bào)錯(cuò) incompatible with sql_mode=only_full_group_by解決方法,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

使用peewee這個(gè)ORM翻譯sql并查詢數(shù)據(jù)

翻譯出來(lái)的 sql 如下,可以看到其實(shí)比較不規(guī)范,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

正常情況下,執(zhí)行上面的 sql 應(yīng)該報(bào)錯(cuò)

SQL 錯(cuò)誤 [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

但是實(shí)際上卻沒(méi)有,為什么?

因?yàn)?peewee 創(chuàng)建連接之后,會(huì)先執(zhí)行 SET sql_mode='PIPES_AS_CONCAT'

具體可看: peewee 創(chuàng)建連接前的前置操作,wireshark 抓包

以上就是mysql 報(bào)錯(cuò) incompatible with sql_mode=only_full_group_by解決的詳細(xì)內(nèi)容,更多關(guān)于mysql incompatible報(bào)錯(cuò)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論