I have the following question:
我有以下问题:
UPDATE users SET posts = posts - 1 WHERE user_id = 5214
However, I think when posts = 0
this query sets posts to 16777214
. How can I get it to stay @ 0 (it's unsigned) if I try to -1
?
但是,我认为当posts = 0时,这个查询将帖子设置为16777214.如果我尝试-1,我怎么能让它保持@ 0(它是无符号的)?
1 个解决方案
#1
1
simply add condition the filters all records which are greater than zero.
只需添加条件过滤器所有大于零的记录。
UPDATE users
SET posts = posts - 1
WHERE user_id = 5214 AND
posts > 0
#1
1
simply add condition the filters all records which are greater than zero.
只需添加条件过滤器所有大于零的记录。
UPDATE users
SET posts = posts - 1
WHERE user_id = 5214 AND
posts > 0