mysql - sql中update语句 and 和直接where语句的区别是什么?
PHP中文网
PHP中文网 2017-04-17 13:47:50
0
3
612
  1. 现在我有如下两条sql请问有什么区别

update customer set moeny = 100 and balance >= 100

udpate customer set money =100 where balance >= 100

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
小葫芦

Let’s talk about the correct way of writing first

udpate customer set money  =100 where balance >= 100

All balance >=100 money=100

Let’s talk about the wrong thing

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还有提醒.

Ty80

So that’s it

刘奇

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!