我将服务器升级到mysql5.7,我对此请求有这个问题:
错误号码:1055
SELECT列表的表达式#1不在GROUP BY子句中并且包含 非聚集列'vuillermoz.pi.id_pierre'不是 功能上依赖于GROUP BY子句中的列;这是 与sql_mode = only_full_group_by
不兼容
SELECT `pi`.`id_pierre`,
`pi`.`couleur_nom`,
`pi`.`couleur_code`,
`pi`.`image`,
count(p.id_prod) AS countproduits
FROM (`produit` p)
LEFT JOIN `categorie` c1_4
ON `p`.`afficher` = `p`.`afficher`
AND p.rid_cat = c1_4.id_cat
AND c1_4.afficher = 1
LEFT OUTER JOIN `categorie` c1_3
ON `c1_4`.`rid_cat` = `c1_3`.`id_cat`
AND c1_3.afficher = '1'
LEFT OUTER JOIN `categorie` c1_2
ON `c1_3`.`rid_cat` = `c1_2`.`id_cat`
AND c1_2.afficher = '1'
LEFT OUTER JOIN `categorie` c1_1
ON `c1_2`.`rid_cat` = `c1_1`.`id_cat`
AND c1_1.afficher = '1'
LEFT OUTER JOIN `type` t
ON `p`.`rid_type` = `t`.`id_type`
INNER JOIN `pierre` pi
ON `p`.`rid_pierre` = `pi`.`id_pierre`
LEFT OUTER JOIN `matiere` ma
ON `p`.`rid_matiere` = `ma`.`id_matiere`
LEFT OUTER JOIN `couleur` co
ON `p`.`rid_couleur` = `co`.`id_couleur`
WHERE `rid_pierre` <> 20
AND `p`.`afficher` = 1
AND (
p.id_prod IN
(
SELECT rid_prod
FROM produit__sexe
WHERE rid_sexe IN ("1")))
AND (
p.id_prod IN
(
SELECT rid_prod
FROM produit__decli
WHERE stock > "0")
OR p.disposurcommande = "1")
GROUP BY `pi`.`couleur_nom`
ORDER BY `couleur_nom` ASC
我可以修复请求而不是更改sql_mode参数吗? 最好的问候
答案 0 :(得分:0)
试试这个
mysql> set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
mysql> set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
答案 1 :(得分:0)
通常,MySQL允许带有非聚合列的SELECT语句 未在GROUP中命名的输出列列表或HAVING子句 BY子句。例如: 选择a,b,COUNT()FROM t GROUP BY a; ONLY_FULL_GROUP_BY标志需要非聚合输出列(或 HAVING列)在GROUP BY中命名: 选择a,b,COUNT()FROM t GROUP BY a,b;