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

mysql報錯sql_mode=only_full_group_by解決

 更新時間:2023年08月23日 14:41:46   作者:朱永勝  
這篇文章主要為大家介紹了mysql報錯sql_mode=only_full_group_by解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪

報錯內(nèi)容

### The error may exist in file[D:\code\cppCode20221025\leader-system\target\classes\mapper\system\TJsonDataMapper.xml]
        ### The error may involve defaultParameterMap
        ### The error occurred while setting parameters
        ### SQL:select ifnull(s.type,'')type,ifnull(GROUP_CONCAT(s.yjzbname,':',s.num),'0')nums from(select t.type,(select name from t_norm s where s.id=n.parentId)yjzbname,count(*)num from t_org_ticket o left join t_ticket t on t.id=o.ticket_id and t.project_id=?left join t_norm n on n.model=t.modelid and n.project_id=?where o.org_id=?and t.type=?and n.type='02'GROUP BY parentId)s
        ### Cause:java.sql.SQLSyntaxErrorException:In aggregated query without GROUP BY,expression #1of SELECT list contains nonaggregated column's.type';this is incompatible with sql_mode=only_full_group_by
        ;bad SQL grammar[];nested exception is java.sql.SQLSyntaxErrorException:In aggregated query without GROUP BY,expression #1of SELECT list contains nonaggregated column's.type';this is incompatible with sql_mode=only_full_group_by

如何解決

調(diào)整GROUP BY子句和SELECT列表:

保證查詢的字段在group by中即可

禁用only_full_group_by模式:

如果你確定查詢的邏輯和數(shù)據(jù)不會引起問題,可以在查詢之前執(zhí)行以下命令來臨時禁用only_full_group_by模式:

SET SESSION sql_mode='';

這可能會導(dǎo)致一些數(shù)據(jù)不一致性問題,只有在你非常確定情況下才應(yīng)該使用。

如果是需要永久寫入,那就需要寫到cnf或ini配置中

mysql中配置文件地址一般是`C:\Program Files\MySQL\MySQL Server 5.7\bin\my.ini

我的在這里額

查詢已經(jīng)有的sql_mode

select @@sql_mode

在ini中添加查詢出來的模式配置,然后去掉only_full_group_by模式即可

[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

重新設(shè)計查詢:

如果無法簡單地調(diào)整GROUP

-->BY子句和SELECT列表,你可能需要重新設(shè)計查詢邏輯。這可能涉及到使用子查詢、臨時表或其他方式來滿足only_full_group_by模式的要求。 。

以上就是mysql報錯sql_mode=only_full_group_by解決的詳細內(nèi)容,更多關(guān)于sql_mode=only_full_group_by的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評論