1. You are using safe update mode and you tried to update a table without a WHERE clause that uses a KEY column.”
原因是在safe mode下,where条件必须使用key column,取消限制 SET SQL_SAFE_UPDATES=0;
2. MYSQL中group_concat有长度限制,默认1024,详细参考 http://blog.csdn.net/catoop/article/details/41805437
3. 分页查询如:select* from (select * from tableA order by time)temp_table left join tableB on ....... limit offset,rows;
使用的mysql版本为5.7.14,遇到两个坑,(1)left join 会打乱原查询顺序,(2)order by的条件为时间戳并且有相同数据时,limit条件不同时查询结果会错乱
4. ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'db_xxx_databases.t_xxx.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
对于GROUP BY聚合操作,如果在SELECT中的列,没有在GROUP BY中出现,那么这个SQL是不合法的,因为列不在GROUP BY从句中,也就是说查出来的列必须在group by后面出现否则就会报错,或者这个字段出现在聚合函数里面。
解决办法: 1.SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
2.在my.cnf文件的[mysqld]字段中,指定sql_mode的值:
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
类似oracle中的decode函数
field函数
http://blog.csdn.net/lxz3000/article/details/6173873
elt函数
http://www.cnblogs.com/lazyx/p/5577105.html
case函数也可实现类似功能