sql_mode = only_full_group_by

时间:2019-12-30 21:18:51

标签: php sql codeigniter

我正在尝试帮助某人在其代码上实现新功能;但是我有这个错误

Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'br_interne.questionnaires_reponses.re_int' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

SELECT `ch_ref` AS id, `ch_date_prevue` AS date, `ch_prestataire_terrassement_branchement` AS prestataire, `re_int` FROM (`questionnaires_contacts`) JOIN `chantiers_osr` ON `ch_ref`=`qc_chantier_id` JOIN `communes` ON `ch_insee`=`co_insee` JOIN `departements` ON `co_departement`=`de_id` LEFT JOIN `questionnaires_reponses` ON `re_questionnaire_contact` = `qc_id` AND re_question = 7 WHERE `de_id` = '78' AND `ch_date_prevue` >= '0000-00-00' AND `qc_chantier_type` = 'osr' AND `qc_invitation_envoyee` = '1' GROUP BY `qc_chantier_id`

不幸的是,如果更改SQL_mode,则请求无效。 (真的很奇怪,因为此代码可在服务器上使用)。

如果您有任何想法。即使使用SQL文档,我也可以找到修改此请求的解决方案。

非常感谢。

1 个答案:

答案 0 :(得分:0)

ONLY_FULL_GROUP_BY控制台中删除MySql

mysql > SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

OR

PHPMyAdmin中的查询下面触发

 SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));