MySQL_group by鎶ラ敊 [ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause]

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL_group by鎶ラ敊 [ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause]相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/%e8%99%9a%e6%8b%9f' title='铏氭嫙'>铏氭嫙   only   渚濇嵁   table   lis   nbsp   sql璇彞   ble   mysq   

浠婂ぉ鏅氫笂鐢佃剳涓婄殑鏁版嵁搴撶獊鐒舵娊椋庯紝鎬庝箞涔熻繛涓嶄笂浜嗭紝鏌ヤ簡濂戒箙鐨勮祫鏂欒鍙兘鏄窡鎴戝湪鏈満鎼缓鐨刯ava椤圭洰鏈夊叧锛岃窡鐫€璧勬枡寮勪簡鍗婂ぉ锛岄棶棰樿繕鏄病鏈夎В鍐筹紝鍙ソ鍙︽眰鍑鸿矾銆?/p>

鎯宠捣涔嬪墠瀹夎杩囦竴涓猯inux铏氭嫙鏈猴紝灏辨兂鍊熺敤铏氭嫙鏈轰笂鐨剆ql锛屾病鎯冲埌鍦ㄥ啓鍒嗙粍鏌ヨ鐨勬椂鍊欎竴鐩存姤涓嬮潰杩欎釜閿欙細

ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 鈥榰ser.t_user.name鈥?which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

 

鍚屾牱鏌ヨ浜嗙綉涓婄殑鏁欑▼锛屽緱鐭ヤ簡闂鍑虹幇鐨勫師鍥狅細

銆€銆€mysql 5.7.5鍙婁互涓婂姛鑳戒緷璧栨娴嬪姛鑳姐€傚鏋滃惎鐢ㄤ簡ONLY_FULL_GROUP_BY SQL妯″紡锛堥粯璁ゆ儏鍐典笅锛夛紝MySQL灏嗘嫆缁濋€夋嫨鍒楄〃锛孒AVING鏉′欢鎴朞RDER BY鍒楄〃鐨勬煡璇㈠紩鐢ㄥ湪GROUP BY瀛愬彞涓棦鏈懡鍚嶇殑闈為泦鍚堝垪锛屼篃涓嶅湪鍔熻兘涓婁緷璧栦簬瀹冧滑銆傦紙5.7.5涔嬪墠锛孧ySQL娌℃湁妫€娴嬪埌鍔熻兘渚濊禆鍏崇郴锛岄粯璁ゆ儏鍐典笅涓嶅惎鐢∣NLY_FULL_GROUP_BY銆傛湁鍏?.7.5涔嬪墠鐨勮涓虹殑璇存槑锛岃鍙傝“MySQL 5.6鍙傝€冩墜鍐?rdquo;銆傦級

涔熷氨鏄濡傛灉鎯冲湪5.7.5涔嬪悗鐨勭増鏈甯镐娇鐢ㄥ垎缁勫姛鑳斤紝鍦╯elect鎸囧畾鐨勫瓧娈佃涔堝氨瑕佸寘鍚湪Group By璇彞鐨勫悗闈綔涓哄垎缁勭殑渚濇嵁锛涜涔堝氨瑕佽鍖呭惈鍦ㄨ仛鍚堝嚱鏁颁腑銆?/strong>

 

瀹樻柟杩欎箞瑙勫畾锛岃嚜鐒舵槸鏈夊畠鐨勯亾鐞嗭紝浣嗘槸鐢ㄤ範鎯簡涔嬪墠鐗堟湰鐨刧roup by锛岃繖涓€鏃跺崐浼氱殑涔熸敼涓嶈繃鏉ャ€?/p>

濂藉湪浠栦篃鍚屾椂鎻愪緵浜嗚В鍐虫柟妗堬紝濡備笅锛?/p>

銆€杈撳叆鏌ヨ璇彞锛?nbsp;   SELECT @@GLOBAL.sql_mode;

鎶€鏈浘鐗? src=

   杈撳叆鏌ヨ璇彞锛?nbsp;    SELECT @@SESSION.sql_mode;

鎶€鏈浘鐗? src= 

 銆€绗竴椤?ONLY_FULL_GROUP_BY 灏辨槸闂鐨勬牴婧愶紝鎴戜滑鎶婂畠鍘绘帀灏卞ソ浜?/span>

銆€ 杈撳叆sql璇彞锛歴et sql_mode=鈥楽TRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION鈥?銆€ 鎶€鏈浘鐗? src=

銆€璁剧疆鎴愬姛涔嬪悗锛屽啀娆℃煡璇ELECT @@SESSION.sql_mode; 灏变細鍙戠幇ONLY_FULL_GROUP_BY 杩欎竴椤瑰凡缁忔病鏈変簡锛屼絾鏄湪GLOBAL閲岄潰杩樹細鏈夛紝浣嗘槸涓嶅奖鍝嶆墽琛岋紝鎵€浠ヤ笉鐢ㄧ灏辫~

鎶€鏈浘鐗? src=

   鍐嶆鎵ц涔嬪墠鐨勫垎缁剆ql璇彞锛屽氨涓嶄細鍐嶆姤閿欏悓鏍风殑閿欏暒 ~~~ 鎾掕姳锛屽紑蹇儈~

 

以上是关于MySQL_group by鎶ラ敊 [ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause]的主要内容,如果未能解决你的问题,请参考以下文章

鎶ラ敊璇?锛?ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'name' of undefin

uiautomatorviewer杩炴帴鏈哄櫒鐐瑰嚮鎶ラ敊Unexpected error while obtaining UI hierarchy

瑙e喅ipython瀹夎鎶ラ敊

Kettle涓璼poon.sh鍦ㄤ娇鐢ㄦ椂鎶ラ敊

cvxpy缁欑殑ADMM_example鎶ラ敊

SQL鎶ラ敊娉ㄥ叆