如何降低数据库中的价值? [英] How Can I Decrease Value In Database?

查看:79
本文介绍了如何降低数据库中的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与图书馆相关的表格,并且如果我给学生发行书籍,在管理网站我想减少书籍的价值,在book_stock表格中可用-1。并在该book_stock表中显示更新的记录。

喜欢,例如。在book_stock表中有16本书的软件工程名称,学生向该书发送了一份请求,图书管理员将该书发给该学生,更新了15本书记录的book_stock表。如何减少记录-1运行时间在PHP?谢谢你.........

i have tables related to library and if i give book to student to issue,at admin site i want to decrease value of book with -1 which available in book_stock table. And display updated records in that book_stock table.
like,e.g. in book_stock table there is 16 books name of software engineering, and student is sent a request to that book and librarian give that book to that student, in book_stock table updated with 15 books records. how can i decrease records -1 run time at php ? thank u .........

推荐答案

假设您正在使用数据库,这是一个相当简单的UPDATE查询:

Assuming you are using a database, it's a fairly simple UPDATE query:
UPDATE MyTable SET inStock = inStock - 1 WHERE BookID=TheIdForTheBookHeBorrowed

将整个内容包含在存储过程中可能是个好主意您可以,或至少在SQL事务中。

It would probably be a good idea to include the whole thing in a stored procedure if you can, or at the least within an SQL Transaction.


您必须在数据库上运行更新查询并减少记录。

例如

在MySQL表中更新数据 [ ^ ]

MySQL UPDATE查询 [ ^ ]



有关更新查询的基础知识 - 更新(SQL) [ ^ ]。
You have to run an update query on the database and decrease the record by .
For e.g.
Update Data In a MySQL Table[^]
MySQL UPDATE Query[^]

For basics on update queries - Update (SQL)[^].


这篇关于如何降低数据库中的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆