{"id":755,"date":"2020-08-02T18:53:59","date_gmt":"2020-08-02T10:53:59","guid":{"rendered":"http:\/\/www.gbase8.cn\/?p=755"},"modified":"2021-09-09T09:52:08","modified_gmt":"2021-09-09T01:52:08","slug":"gbase-8a%e6%95%b0%e6%8d%ae%e5%ba%93%e9%9b%86%e7%be%a4%e6%9f%a5%e8%af%a2%e6%8a%a5%e9%94%99-error-1055-42000-testdb-t2-c-isnt-in-group-by","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/755","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a\u6570\u636e\u5e93\u96c6\u7fa4\u67e5\u8be2\u62a5\u9519 ERROR 1055 (42000): 'testdb.t2.c' isn't in GROUP BY"},"content":{"rendered":"<p>GBase 8a\u6570\u636e\u5e93\u96c6\u7fa4\uff0c\u5728\u5904\u7406group\u7684select \u5217\u65f6\uff0c\u8981\u6c42\u5176\u5fc5\u987b\u662fgroup\u7684\u5217\u6216\u8005\u805a\u5408\u8fd0\u7b97\u7684\u5217\uff0c\u5426\u5219\u4f1a\u62a5isn't in GROUP BY\u7684\u9519\u8bef\u3002<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Directory Navigation<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2b3cf9a665a\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2b3cf9a665a\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/755\/#%E5%8E%9F%E5%9B%A0%EF%BC%9A\" >\u539f\u56e0\uff1a<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.gbase8.cn\/en\/755\/#%E8%A7%A3%E5%86%B3%EF%BC%9A\" >\u89e3\u51b3\uff1a<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/755\/#%E4%BF%AE%E6%94%B9SQL_MODE%E7%9A%84%E4%BE%8B%E5%AD%90\" >\u4fee\u6539SQL_MODE\u7684\u4f8b\u5b50<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.gbase8.cn\/en\/755\/#%E6%95%B0%E6%8D%AE\" >\u6570\u636e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.gbase8.cn\/en\/755\/#%E6%9F%A5%E8%AF%A2%E6%95%88%E6%9E%9C\" >\u67e5\u8be2\u6548\u679c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.gbase8.cn\/en\/755\/#%E4%BF%AE%E6%94%B9%E5%8F%82%E6%95%B0\" >\u4fee\u6539\u53c2\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.gbase8.cn\/en\/755\/#%E5%86%8D%E6%AC%A1%E6%9F%A5%E8%AF%A2\" >\u518d\u6b21\u67e5\u8be2<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8E%9F%E5%9B%A0%EF%BC%9A\"><\/span>\u539f\u56e0\uff1a<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>select\u7684\u5217\uff0c\u4e0d\u662fgroup\u7684\u5217\uff0c\u4e5f\u4e0d\u662f\u805a\u5408\u5217\u3002\u5728\u65b0\u7248\u768485\u548c\u6240\u670986\u7248\u672c\u91cc\uff0c\u4e0d\u518d\u5141\u8bb8\u975egroup\u548c\u805a\u5408\u5217\u51fa\u73b0\u5728select\u91cc\u9762\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; desc t2;\n+-------+---------+------+-----+---------+-------+\n| Field | Type    | Null | Key | Default | Extra |\n+-------+---------+------+-----+---------+-------+\n| a     | int(11) | YES  |     | NULL    |       |\n| b     | int(11) | YES  |     | NULL    |       |\n| c     | int(11) | YES  |     | NULL    |       |\n+-------+---------+------+-----+---------+-------+\n3 rows in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select a,sum(b),c from t2 group by a;\nERROR 1055 (42000): 'testdb.t2.c' isn't in GROUP BY\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%A7%A3%E5%86%B3%EF%BC%9A\"><\/span>\u89e3\u51b3\uff1a<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>a)\u53bb\u6389\u4e0d\u7b26\u5408\u8981\u6c42\u7684\u5217\u3002\u5f3a\u70c8\u5efa\u8bae\u5982\u6b64\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>b)\u6062\u590d\u5230\u8001\u7248\u672c\u7684\u517c\u5bb9\u6a21\u5f0f\uff0c\u4f46\u4ece\u8bed\u4e49\u4e0a\u65e0\u6cd5\u4fdd\u8bc1\u7ed3\u679c\u7684\u4e00\u81f4\u6027\u3002<\/p>\n\n\n\n<p>\u5c06\u96c6\u7fa4\u53c2\u6570SQL_MODE\u4e2d\u7684ONLY_FULL_GROUP_BY\u53bb\u6389\u3002\u9ed8\u8ba4\u503c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ONLY_FULL_GROUP_BY,NO_AUTO_VALUE_ON_ZERO,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PAD_CHAR_TO_FULL_LENGTH<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%BF%AE%E6%94%B9SQL_MODE%E7%9A%84%E4%BE%8B%E5%AD%90\"><\/span>\u4fee\u6539SQL_MODE\u7684\u4f8b\u5b50<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%95%B0%E6%8D%AE\"><\/span>\u6570\u636e<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> select * from a1;\r\n+------+------+------------+--------+\r\n| id   | name | birthday   | salary |\r\n+------+------+------------+--------+\r\n|    1 | 1111 | 2011-11-11 |  10000 |\r\n|    2 | 2222 | 2011-12-12 |  20000 |\r\n|    3 | 3333 | 2011-12-13 |  10000 |\r\n+------+------+------------+--------+\r\n3 rows in set (Elapsed: 00:00:00.01)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%9F%A5%E8%AF%A2%E6%95%88%E6%9E%9C\"><\/span>\u67e5\u8be2\u6548\u679c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u5305\u542b\u4e0d\u7b26\u5408\u6761\u4ef6\u7684\u5217\u65f6\uff0c\u76f4\u63a5\u62a5\u9519 ERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> select max(salary) from a1;\r\n+-------------+\r\n| max(salary) |\r\n+-------------+\r\n|       20000 |\r\n+-------------+\r\n1 row in set (Elapsed: 00:00:00.02)\r\n\r\ngbase> select id,name,birthday,max(salary) from a1;\r\nERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%BF%AE%E6%94%B9%E5%8F%82%E6%95%B0\"><\/span>\u4fee\u6539\u53c2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> show variables like '%sql_mode%';\r\n+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\r\n| Variable_name | Value                                                                                                                                                                                               |\r\n+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\r\n| sql_mode      | PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ONLY_FULL_GROUP_BY,NO_AUTO_VALUE_ON_ZERO,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PAD_CHAR_TO_FULL_LENGTH |\r\n+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\r\n1 row in set (Elapsed: 00:00:00.00)\r\n\r\ngbase> set sql_mode='PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,NO_AUTO_VALUE_ON_ZERO,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PAD_CHAR_TO_FULL_LENGTH';\r\nQuery OK, 0 rows affected (Elapsed: 00:00:00.00)\r\n\r\ngbase> show variables like '%sql_mode%';\r\n+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\r\n| Variable_name | Value                                                                                                                                                                            |\r\n+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\r\n| sql_mode      | PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,NO_AUTO_VALUE_ON_ZERO,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PAD_CHAR_TO_FULL_LENGTH |\r\n+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\r\n1 row in set (Elapsed: 00:00:00.01)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%86%8D%E6%AC%A1%E6%9F%A5%E8%AF%A2\"><\/span>\u518d\u6b21\u67e5\u8be2<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u4e0d\u7b26\u5408\u6761\u4ef6\u7684\u5217\uff0c\u53ef\u4ee5\u67e5\u8be2\u51fa\u6765\u4e86\uff0c\u4f46\u5176\u53ea\u662f\u4ece\u7b26\u5408where\u548cgroup\u5206\u7ec4\u7684\u6570\u636e\u4e2d\uff0c\u4efb\u610f\u9009\u4e00\u884c\u8fd4\u56de\uff0c\u4e0d\u786e\u4fdd\u987a\u5e8f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> select id,name, max(birthday),salary from a1;\r\n+------+------+---------------+--------+\r\n| id   | name | max(birthday) | salary |\r\n+------+------+---------------+--------+\r\n|    1 | 1111 | 2011-12-13    |  10000 |\r\n+------+------+---------------+--------+\r\n1 row in set (Elapsed: 00:00:00.03)\r\n\r\ngbase> select id,name, max(birthday),salary from a1 group by salary;\r\n+------+------+---------------+--------+\r\n| id   | name | max(birthday) | salary |\r\n+------+------+---------------+--------+\r\n|    1 | 1111 | 2011-12-13    |  10000 |\r\n|    2 | 2222 | 2011-12-12    |  20000 |\r\n+------+------+---------------+--------+\r\n2 rows in set (Elapsed: 00:00:00.06)<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>\u5357\u5927\u901a\u7528GBase 8a\u6570\u636e\u5e93\u96c6\u7fa4\uff0c\u5728\u5904\u7406group\u7684select \u5217\u65f6\uff0c\u8981\u6c42\u5176\u5fc5\u987b\u662fgroup\u7684\u5217\u6216\u8005\u805a\u5408\u8fd0\u7b97\u7684\u5217\uff0c\u5426\u5219\u4f1a\u62a5isn't in GROUP BY\u7684\u9519\u8bef\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54],"tags":[],"class_list":["post-755","post","type-post","status-publish","format-standard","hentry","category-gbase8a"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=755"}],"version-history":[{"count":7,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/755\/revisions"}],"predecessor-version":[{"id":7919,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/755\/revisions\/7919"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}