首页 > 数据库技术 > 详细

Mysql字段int的value为0时产生的bug

时间:2020-02-13 17:26:47      阅读:91      评论:0      收藏:0      [点我收藏+]

查询

userId 在数据库中为int类型

select * from userinfo where userId = 0

等于

select * from userinfo where userId = ‘‘

容易出现bug

当id为int类型,根据id批量(逻辑)删除记录时。

update userinfo set isdel = 1 where userId in(‘‘)

这里尽管没有删除,但是空字符串会被当成0来执行。会把id为0的删除掉。

解决办法就是当id不存在时不执行此语句。 

Mysql字段int的value为0时产生的bug

原文:https://www.cnblogs.com/aeolian/p/12303951.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!