Database export sql - Please tell me how to write mysql batch database export statement. Can it be implemented in one sentence?

WBOY
Release: 2016-12-05 13:27:35
Original
1572 people have browsed it

Mysql export sql

 订单表trade字段:stock_num 已使用库存数字段:num 商品总数字段:num_iid 商品id
Copy after login
 商品表goods字段:total_stock_num 总库存数字段:num_iid 商品id
Copy after login

Requirements to achieve:
Automatically reduce the number of total_stock_num, then set it to stock_num, and update the value of total_stock_num at the same time

Note:
1. stock_num may already have a value, where to reduce When adding the original value, it is required that stock_num<=num
2. total_stock_num may be 0, may be less than num (then subtract as much as you want), or may be greater than num (this can be subtracted directly)

I don’t have any coins, what should I do? Can anyone help me with the answer? Thank you
Since there are thousands of orders to be shipped out in batches, what I currently think of is to query and process them in the program, but this will require a lot of SQL to be executed

 例子1:stock_num=2 num=5 total_stock_num=100出库后:stock_num=5 num=5 total_stock_num=97
Copy after login
 例子2:stock_num=0 num=5 total_stock_num=100出库后:stock_num=5 num=5 total_stock_num=95
Copy after login
 例子3:stock_num=2 num=5 total_stock_num=2出库后:stock_num=4 num=5 total_stock_num=0
Copy after login

Reply content:

Use MYSQL -uroot -p123

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
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!