当前位置:网站首页>sql_ mode=only_ full_ group_ By's pit
sql_ mode=only_ full_ group_ By's pit
2022-06-25 04:20:00 【Robin Luo Bing】
One 、 Translate a paragraph , English is not good , Forgive me
Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'a16.a.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
Syntax: grammar .violation: It is illegal to .Expression: expression . clause: clause .contains: contain .nonaggregated: Non aggregation .functionally: Functionality .dependent: rely on .incompatible: Are not compatible
Two 、only_full_group_by:
1、 This rule requires : Where there are group by The fields that appear later , Must be at the same time select Behind the ; Where there are select Later on 、 Fields that do not appear in the aggregate function at the same time , Must appear at the same time group by Back ”, Check sql Compliance with the above rules .
2、order by The following columns must be in select There is something behind it
3、select、having or order by The following non aggregate columns must all be in group by in
https://zhuanlan.zhihu.com/p/103283746
3、 ... and 、 Aggregate functions ( Combinatorial function ): Aggregate functions aggregation function Also called group function . By default The aggregate function will count the current table as a group .https://www.cnblogs.com/xuchuankun/p/9483765.html
Four 、GROUP BY sentence :GROUP BY Statements are used to combine aggregate functions , Group result sets according to one or more columns .
5、 ... and 、group by Detailed explanation :https://blog.csdn.net/jerrytomcat/article/details/82351605
https://blog.csdn.net/s00229295/article/details/96041555
6、 ... and 、Having And Where The difference between
where Clause is used before grouping query results , Will not meet where The line of the condition is removed , Filtering data before grouping ,where A condition cannot contain a grouper function , Use where Conditions filter out specific lines .
having Clause is used to filter groups that meet the conditions , Filtering data after grouping , Conditions often include groupings , Use having Conditions filter out specific groups , You can also use multiple grouping criteria for grouping .
7、 ... and 、MYSQL in GROUP BY Do not include all non aggregated fields :https://blog.csdn.net/liufei198613/article/details/82979034
8、 ... and 、 Multi table queries do not seem to follow the above rules : The following code does not report an error , What's the reason ?
$map['a.user_id'] = $this->auth->id;
$map['b.type'] = 1;
$map['b.deletetime'] = null;
$map['b.endtime'] = ['>', time()];
$map['b.starttime'] = ['<', time()];
$field = 'a.id, a.plan_id, b.plan_name, b.times, b.hours, b.endtime, b.starttime,b.type,b.exam_id,c.exam_name, max(d.lasttime) as lasttime';
$plans = $this->model
->alias('a')
->where($map)
->field($field)
->join('__KAOSHI_PLAN__ b', 'a.plan_id = b.id')
->join('__KAOSHI_EXAMS__ c', 'b.exam_id = c.id')
->join('__KAOSHI_USER_EXAMS__ d', 'a.id = d.user_plan_id', 'left')
->group('a.id, b.id')
->select();
边栏推荐
- Cesium drag 3D model
- 【LeetCode】143. 重排链表
- SQL, CTE, FLG CASE问题
- 小心被偷脸!天天用的人脸识别风险原来这么多?
- Zoran community
- Development of trading system (VII) -- Analysis of trading delay
- Lecture record: new application of inertial navigation - inertial measurement
- Intel 13th generation core showed its true colors for the first time: 68mb cache improved significantly
- PHP代码审计2—这些函数必知必会
- 95% 程序员都在这里摸鱼……
猜你喜欢
Lecture record: data processing methods and applications of various spatial geodetic techniques
"Renaissance" in the digital age? The bottom digital collection makes people happy and sad
“语法糖”——我的编程新知
Turn 2D photos into 3D models to see NVIDIA's new AI "magic"!
《悉达多》:一生之书,可以时常反刍
Watch out for the stolen face! So many risks of face recognition used every day?
cesium 图形标注圆形、正方形、多边形、椭圆等
Error 1062 is reported during MySQL insertion, but I do not have this field.
Hot and cold, sweet and sour, want to achieve success? Dengkang oral, the parent company of lengsuanling, intends to be listed on the main board of Shenzhen Stock Exchange
Development of trading system (II) -- market data
随机推荐
UCLA | 用于黑盒优化的生成式预训练
client-go gin的简单整合十-Update
[proteus simulation] Arduino uno key controls the flashing increase / decrease display of nixie tube
Coinlist how to operate the middle lot number security tutorial
numpy np tips:使用opencv对数组插值放缩到固定形状 cv2.resize(res, dsize=(64, 64), interpolation=cv2.INTER_CUBIC)
Interview with Mo Tianlun | ivorysql wangzhibin - ivorysql, an Oracle compatible open source database based on PostgreSQL
NFT insider 63: the sandbox reached a cooperation with Time magazine, and YGG established Spain's subdao
Hello CTP (V) -- CTP position calculation
How much do you know about the use value of WMS warehouse management system
BSC smart contract dividend mainstream currency | including marketing wallet | deflation | reflow | dividend free token | available for direct deployment
Finereport displays and hides column data according to conditions
MySQL order by
《悉达多》:一生之书,可以时常反刍
Laravel document sorting 2. Route related
【LeetCode】148. 排序链表
WMS仓储管理系统的使用价值,你知道多少
数学分析_笔记_第3章:极限
【LeetCode】22. bracket-generating
[team learning] SQL programming language notes - task04
Laravel document sorting 3. CSRF protection