mysql实际碰到问题汇总

问题1:SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'muwms.middle_goods_trace.size' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
出现这种问题 直接修改my.cnf 即可
在mysqld下面添加sql_mode="" 然后保存 -》重启mysql 完活

 

问题2:ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
产生这个问题的原因是因为在mysql中产生了事务A,执行了修改的语句,比如: update t1 set aget=18 where id=1;此时事务并未进行提交,事务B开始运行,也同样需要修改id为1的用户的年龄: update t1 set aget=20 where id=1; 那么此时事务B会等待事务A结束释放写锁才能执行成功,否则则会等待一段时间。
解决方法:https://www.cnblogs.com/topicjie/p/7323248.html

 

问题3:1292-Truncated incorrect DOUBLE value

产生原因执行 update middle_goods_XX set sku=100763 where sku=100762 ,middle_goods_XX这张表的sku是varchar类型

解决方法update middle_goods_XX set sku='100763' where sku='100762'

 

问题4:跟新操作时出现 You can't specify target table for update in FROM clause

比如我执行
UPDATE woms_wms_allocation_order
SET STATUS = 'success'
WHERE
number IN ( SELECT number FROM woms_wms_allocation_order WHERE STATUS = 'process' AND type = 'repair' )
解决方法:select的结果再通过一个中间表select多一次,就可以避免这个错误
将上述语句的select语句加一个中间表,具体如下:
update woms_wms_allocation_order set status='success' where number in ( select number from (
select number from woms_wms_allocation_order where status='process' and type='repair' ) a )

posted on 2019-04-30 18:54  Ryanyanglibin  阅读(...)  评论(...编辑  收藏

导航