首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

mysql中这条语句如何会出错

2012-11-07 
mysql中这条语句怎么会出错?SQL codestart transactionupdate participants set cashcash-12.99 where i

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;


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

热点排行