sql数据库如何实现int类型数值相加减?
目前正在做个借书系统,针对书本数量的增减来实现借出归还功能,请各位大大帮下忙看下这个代码应该如何编写,不胜感激!!
[解决办法]
假如表tb有个字段total_count表示数量
则:
增加1本:
update tb set total_count=total_count+1 where 条件
减少1本:
update tb set total_count=total_count-1 where 条件
发布时间: 2012-02-08 19:52:21 作者: rapoo
sql数据库如何实现int类型数值相加减?
目前正在做个借书系统,针对书本数量的增减来实现借出归还功能,请各位大大帮下忙看下这个代码应该如何编写,不胜感激!!
[解决办法]
假如表tb有个字段total_count表示数量
则:
增加1本:
update tb set total_count=total_count+1 where 条件
减少1本:
update tb set total_count=total_count-1 where 条件