MySQL
可能遇到的问题
[ERR] 2006 - MySQL server has gone away
问题描述
将MySQL8.0的脚本文件运行在MySQL5.7上,语句太长了:Your SQL statement was too large
解决方案
set global max_allowed_packet=1024*1024*160;
show global variables like 'max_allowed_packet'
参考链接
【1】https://blog.csdn.net/helloxiaozhe/article/details/78116871
三元运算符
语法:select *,if(expr1,expr2,expr3) from 表名
select QUARTER(time) AS quarter, b.category_id as categoryId, count(*) as count, if(b.category_id=0, sum(price_fixes), sum(price_install)) as sum from mt_contract a left join mt_fix_record b on a.mt_id=b.mt_id group by b.category_id, quarter