现在我有如下两条sql请问有什么区别?
update customer set moeny = 100 and balance >= 100
udpate customer set money =100 where balance >= 100
高洛峰2017-04-17 13:49:50
udpate customer set money =100 where balance >= 100
All balance >=100 money=100
update customer set moeny = 100 and balance >= 100
This error is serious, 会把全局的money变为默认值,通常是0
The reason is: if there is no where, it is a global set. The multiple setting methods in the set are ','; if and is used, it will be considered as the setting of money, money = (100 and balance >=100), However, the value of this expression is unrecognized and becomes the default value.
So: the global money becomes the default value, which is very cheating, delete和update千万记得加where,尤其update,因为delete还有提醒
.
怪我咯2017-04-17 13:49:50
update customer set moeny = 100 and balance >= 100
;
=>update customer set moeny = (100 and balance >= 100)
;
That is to say, moeny is all set to 1 or 0.