mysql中这条语句怎么会出错?
SQL code
start transaction; update participants set cash=cash-12.99 where id=1; update participants set cash=cash+12.99 where id=2; update trunks set owner=1 where name='Abacus' and owner=2; select * from participants;
欢迎大家阅读《mysql中这条语句如何会出错》,跪求各位点评,by 搞代码
update trunks set owner=1 where name='Abacus' and owner=2;这条语句出错:
You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
为什么会这样??我的记录,字段,类型都没有错的,而且我在my.ini中也#safe-mode了,为什么还是这样子呢?
------解决方案--------------------
SET SQL_SAFE_UPDATES=0;
再试试
使用安全更新模式的时候update语句必须使用一个关键字列属性来限定更新的范围。如果不使用关键字列来限定范围或更新所有记录的时候就不能用安全更新模式。
解决办法是执行以下语句设置为非安全更新模式.
SET SQL_SAFE_UPDATES=0;
------解决方案--------------------
show variables like '%sql_safe_update%';看看sql_safe_update的值是什么
如果是on 就在执行set sql_safe_updates=off
原创文章,转载请注明: 转载自搞代码
微信 赏一包辣条吧~
支付宝 赏一听可乐吧~