pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  1. <tfoot id='KXRtr'></tfoot>

  2. <small id='KXRtr'></small><noframes id='KXRtr'>

    1. <i id='KXRtr'><tr id='KXRtr'><dt id='KXRtr'><q id='KXRtr'><span id='KXRtr'><b id='KXRtr'><form id='KXRtr'><ins id='KXRtr'></ins><ul id='KXRtr'></ul><sub id='KXRtr'></sub></form><legend id='KXRtr'></legend><bdo id='KXRtr'><pre id='KXRtr'><center id='KXRtr'></center></pre></bdo></b><th id='KXRtr'></th></span></q></dt></tr></i><div class="rf7rjpp" id='KXRtr'><tfoot id='KXRtr'></tfoot><dl id='KXRtr'><fieldset id='KXRtr'></fieldset></dl></div>
    2. <legend id='KXRtr'><style id='KXRtr'><dir id='KXRtr'><q id='KXRtr'></q></dir></style></legend>
      • <bdo id='KXRtr'></bdo><ul id='KXRtr'></ul>

      在 MySql 中執行查詢時與 only_full_group_by 相關的錯

      Error related to only_full_group_by when executing a query in MySql(在 MySql 中執行查詢時與 only_full_group_by 相關的錯誤)
      <tfoot id='q9oIj'></tfoot>
      <legend id='q9oIj'><style id='q9oIj'><dir id='q9oIj'><q id='q9oIj'></q></dir></style></legend>
        <bdo id='q9oIj'></bdo><ul id='q9oIj'></ul>

        <small id='q9oIj'></small><noframes id='q9oIj'>

          <tbody id='q9oIj'></tbody>
        <i id='q9oIj'><tr id='q9oIj'><dt id='q9oIj'><q id='q9oIj'><span id='q9oIj'><b id='q9oIj'><form id='q9oIj'><ins id='q9oIj'></ins><ul id='q9oIj'></ul><sub id='q9oIj'></sub></form><legend id='q9oIj'></legend><bdo id='q9oIj'><pre id='q9oIj'><center id='q9oIj'></center></pre></bdo></b><th id='q9oIj'></th></span></q></dt></tr></i><div class="pxf5pxl" id='q9oIj'><tfoot id='q9oIj'></tfoot><dl id='q9oIj'><fieldset id='q9oIj'></fieldset></dl></div>

              • 本文介紹了在 MySql 中執行查詢時與 only_full_group_by 相關的錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我已經升級了我的系統并為我正在開發的 Web 應用程序安裝了帶有 php 的 MySql 5.7.9.我有一個動態創建的查詢,當在舊版本的 MySql 中運行時,它工作正常.升級到 5.7 后,我收到此錯誤:

                I have upgraded my system and have installed MySql 5.7.9 with php for a web application I am working on. I have a query that is dynamically created, and when run in older versions of MySql it works fine. Since upgrading to 5.7 I get this error:

                SELECT 列表的表達式 #1 不在 GROUP BY 子句中并且包含非聚合列support_desk.mod_users_groups.group_id"是在功能上不依賴于 GROUP BY 子句中的列;這是與 sql_mode=only_full_group_by 不兼容

                Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'support_desk.mod_users_groups.group_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

                注意關于服務器SQL模式.

                這是給我帶來麻煩的查詢:

                This is the query that is giving me trouble:

                SELECT mod_users_groups.group_id AS 'value', 
                       group_name AS 'text' 
                FROM mod_users_groups
                LEFT JOIN mod_users_data ON mod_users_groups.group_id = mod_users_data.group_id 
                WHERE  mod_users_groups.active = 1 
                  AND mod_users_groups.department_id = 1 
                  AND mod_users_groups.manage_work_orders = 1 
                  AND group_name != 'root' 
                  AND group_name != 'superuser' 
                GROUP BY group_name 
                HAVING COUNT(`user_id`) > 0 
                ORDER BY group_name
                

                我對這個問題進行了一些谷歌搜索,但我對 only_full_group_by 的了解不足以弄清楚我需要做什么來修復查詢.我可以關閉 only_full_group_by 選項,還是我需要做其他事情?

                I did some googling on the issue, but I don't understand only_full_group_by enough to figure out what I need to do to fix the query. Can I just turn off the only_full_group_by option, or is there something else I need to do?

                如果您需要更多信息,請告訴我.

                Let me know if you need more information.

                推薦答案

                我只想將 group_id 添加到 GROUP BY.

                I would just add group_id to the GROUP BY.

                SELECT 不屬于 GROUP BY 的列時,組內該列可能有多個值,但只有一個空間結果中的單個值.因此,數據庫通常需要被告知如何將這些多個值變成一個值.通常,這是通過一個聚合函數來完成的,比如 COUNT()SUM()MAX() 等等......我說通常因為大多數其他流行的數據庫系統都堅持這一點.但是,在 MySQL 5.7 之前的版本中,默認行為更加寬容,因為它不會抱怨然后任意選擇任何值!它還有一個 ANY_VALUE() 函數,如果你真的需要和以前一樣的行為,它可以用作這個問題的另一種解決方案.這種靈活性是有代價的,因為它是不確定的,所以除非你有充分的理由需要它,否則我不會推薦它.MySQL 現在默認打開 only_full_group_by 設置有充分的理由,所以最好習慣它并使您的查詢符合它.

                When SELECTing a column that is not part of the GROUP BY there could be multiple values for that column within the groups, but there will only be space for a single value in the results. So, the database usually needs to be told exactly how to make those multiple values into one value. Commonly, this is done with an aggregate function like COUNT(), SUM(), MAX() etc... I say usually because most other popular database systems insist on this. However, in MySQL prior to version 5.7 the default behaviour has been more forgiving because it will not complain and then arbitrarily choose any value! It also has an ANY_VALUE() function that could be used as another solution to this question if you really needed the same behaviour as before. This flexibility comes at a cost because it is non-deterministic, so I would not recommend it unless you have a very good reason for needing it. MySQL are now turning on the only_full_group_by setting by default for good reasons, so it's best to get used to it and make your queries comply with it.

                那為什么我上面的簡單回答是?我做了幾個假設:

                So why my simple answer above? I've made a couple of assumptions:

                1) group_id 是唯一的.看起來有道理,畢竟是一個ID".

                1) the group_id is unique. Seems reasonable, it is an 'ID' after all.

                2) group_name 也是唯一的.這可能不是一個合理的假設.如果不是這種情況,并且您有一些重復的 group_names,然后您按照我的建議將 group_id 添加到 GROUP BY,您可能會發現您現在可以獲得比以前更多的結果,因為具有相同名稱的組現在將在結果中具有單獨的行.對我來說,這比隱藏這些重復組要好,因為數據庫已經悄悄地任意選擇了一個值!

                2) the group_name is also unique. This may not be such a reasonable assumption. If this is not the case and you have some duplicate group_names and you then follow my advice to add group_id to the GROUP BY, you may find that you now get more results than before because the groups with the same name will now have separate rows in the results. To me, this would be better than having these duplicate groups hidden because the database has quietly selected a value arbitrarily!

                當涉及多個表時,用它們的表名或別名來限定所有列也是一種很好的做法......

                It's also good practice to qualify all the columns with their table name or alias when there's more than one table involved...

                SELECT 
                  g.group_id AS 'value', 
                  g.group_name AS 'text' 
                FROM mod_users_groups g
                LEFT JOIN mod_users_data d ON g.group_id = d.group_id 
                WHERE g.active = 1 
                  AND g.department_id = 1 
                  AND g.manage_work_orders = 1 
                  AND g.group_name != 'root' 
                  AND g.group_name != 'superuser' 
                GROUP BY 
                  g.group_name, 
                  g.group_id 
                HAVING COUNT(d.user_id) > 0 
                ORDER BY g.group_name
                

                這篇關于在 MySql 中執行查詢時與 only_full_group_by 相關的錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數根據 N 個先前值來決定接下來的 N 個行)
                reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達式的結果;條款?)
                Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數的 ignore 選項是忽略整個事務還是只是有問題的行?) - IT屋-程序員軟件開發技
                Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時出錯,使用 for 循環數組)
                pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調用 o23.load 時發生錯誤 沒有合適的驅動程序)
                How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數據庫表作為 Spark 數據幀讀取?)
              • <legend id='Fi8Xe'><style id='Fi8Xe'><dir id='Fi8Xe'><q id='Fi8Xe'></q></dir></style></legend>
                  <tbody id='Fi8Xe'></tbody>

                <tfoot id='Fi8Xe'></tfoot>

                  <bdo id='Fi8Xe'></bdo><ul id='Fi8Xe'></ul>
                • <i id='Fi8Xe'><tr id='Fi8Xe'><dt id='Fi8Xe'><q id='Fi8Xe'><span id='Fi8Xe'><b id='Fi8Xe'><form id='Fi8Xe'><ins id='Fi8Xe'></ins><ul id='Fi8Xe'></ul><sub id='Fi8Xe'></sub></form><legend id='Fi8Xe'></legend><bdo id='Fi8Xe'><pre id='Fi8Xe'><center id='Fi8Xe'></center></pre></bdo></b><th id='Fi8Xe'></th></span></q></dt></tr></i><div class="nlblbjn" id='Fi8Xe'><tfoot id='Fi8Xe'></tfoot><dl id='Fi8Xe'><fieldset id='Fi8Xe'></fieldset></dl></div>

                    1. <small id='Fi8Xe'></small><noframes id='Fi8Xe'>

                          主站蜘蛛池模板: 升降机-高空作业车租赁-蜘蛛车-曲臂式伸缩臂剪叉式液压升降平台-脚手架-【普雷斯特公司厂家】 | 雾度仪_雾度计_透光率雾度仪价格-三恩时(3nh)光电雾度仪厂家 | 江苏密集柜_电动_手动_移动_盛隆柜业江苏档案密集柜厂家 | 缓蚀除垢剂_循环水阻垢剂_反渗透锅炉阻垢剂_有机硫化物-郑州威大水处理材料有限公司 | 灰板纸、灰底白、硬纸板等纸品生产商-金泊纸业| 创客匠人-让IP变现不走弯路 | 钢格板|热镀锌钢格板|钢格栅板|钢格栅|格栅板-安平县昊泽丝网制品有限公司 | 阴离子_阳离子聚丙烯酰胺厂家_聚合氯化铝价格_水处理絮凝剂_巩义市江源净水材料有限公司 | 智能化的检漏仪_气密性测试仪_流量测试仪_流阻阻力测试仪_呼吸管快速检漏仪_连接器防水测试仪_车载镜头测试仪_奥图自动化科技 | 皮带机_移动皮带机_大倾角皮带机_皮带机厂家 - 新乡市国盛机械设备有限公司 | 不锈钢发酵罐_水果酒发酵罐_谷物发酵罐_山东誉诚不锈钢制品有限公司 | 分轨 | 上传文件,即刻分离人声和伴奏| 大型工业风扇_工业大风扇_大吊扇_厂房车间降温-合昌大风扇 | led全彩屏-室内|学校|展厅|p3|户外|会议室|圆柱|p2.5LED显示屏-LED显示屏价格-LED互动地砖屏_蕙宇屏科技 | 扒渣机,铁水扒渣机,钢水扒渣机,铁水捞渣机,钢水捞渣机-烟台盛利达工程技术有限公司 | 标准件-非标紧固件-不锈钢螺栓-非标不锈钢螺丝-非标螺母厂家-三角牙锁紧自攻-南京宝宇标准件有限公司 | 艺术涂料_进口艺术涂料_艺术涂料加盟_艺术涂料十大品牌 -英国蒙太奇艺术涂料 | 新能源汽车电池软连接,铜铝复合膜柔性连接,电力母排-容发智能科技(无锡)有限公司 | 齿轮减速机电机一体机_齿轮减速箱加电机一体化-德国BOSERL蜗轮蜗杆减速机电机生产厂家 | 儿童语言障碍训练-武汉优佳加感统文化发展有限公司 | 微波消解仪器_智能微波消解仪报价_高压微波消解仪厂家_那艾 | 合肥卓创建筑装饰,专业办公室装饰、商业空间装修与设计。 | LNG鹤管_内浮盘价格,上装鹤管,装车撬厂家-连云港赛威特机械 | 江苏大隆凯科技有限公司 | 算命免费_生辰八字_免费在线算命 - 卜算子算命网 | 广州昊至泉水上乐园设备有限公司 | 电动葫芦|防爆钢丝绳电动葫芦|手拉葫芦-保定大力起重葫芦有限公司 | 酒瓶_酒杯_玻璃瓶生产厂家_徐州明政玻璃制品有限公司 | 双能x射线骨密度检测仪_dxa骨密度仪_双能x线骨密度仪_品牌厂家【品源医疗】 | 工业PH计|工业ph酸度计|在线PH计价格-合肥卓尔仪器仪表有限公司 济南画室培训-美术高考培训-山东艺霖艺术培训画室 | UV固化机_UVLED光固化机_UV干燥机生产厂家-上海冠顶公司专业生产UV固化机设备 | 阴离子_阳离子聚丙烯酰胺厂家_聚合氯化铝价格_水处理絮凝剂_巩义市江源净水材料有限公司 | 成都竞价托管_抖音代运营_网站建设_成都SEM外包-成都智网创联网络科技有限公司 | HDPE储罐_厂家-山东九州阿丽贝防腐设备 | 翅片管换热器「型号全」_厂家-淄博鑫科环保 | 北京普辉律师事务所官网_北京律师24小时免费咨询|法律咨询 | 安徽控制器-合肥船用空调控制器-合肥家电控制器-合肥迅驰电子厂 安徽净化板_合肥岩棉板厂家_玻镁板厂家_安徽科艺美洁净科技有限公司 | 置顶式搅拌器-优莱博化学防爆冰箱-磁驱搅拌器-天津市布鲁克科技有限公司 | POS机办理_个人pos机免费领取-银联pos机申请首页 | 共享雨伞_共享童车_共享轮椅_共享陪护床-共享产品的领先者_有伞科技 | 橡胶接头_橡胶软接头_套管伸缩器_管道伸缩器厂家-巩义市远大供水材料有限公司 |