| |

VerySource

 Forgot password?
 Register
Search
View: 801|Reply: 4

Find an update insert statement online, please everyone!

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-30 01:00:02
| Show all posts |Read mode
Table A

Code Name quantity
001 TV 100
002 Refrigerator 200

Desired effect:
Code Name quantity
001 TV 80
002 Refrigerator 200
001 TV 20
Note: If I update the number of 001 in the interface to 20; at this time, I insert a new one and change the original number to 80; if I update it, the new number exceeds 80 and it will not operate.
Please give an example
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-18 18:00:01
| Show all posts
The expression is not very clear.It seems that your question should not be considered from the SQL statement.
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 Invalid IP Address

Post time: 2020-3-24 10:00:01
| Show all posts
I want to ask you, if I update again this time, and this time I want to update 10, should I reduce it in 80 or decrease it in 20? ?
Reply

Use magic Report

0

Threads

22

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-7-25 19:00:01
| Show all posts
I think what he meant is that every update is split from the original record
How about this:
1. Find the most original one
2. The input parameter is compared with the number of 1, and the update is allowed if it is less than or equal to; otherwise, exit
3. Insert a record with the parameter of 2
4. Correspondingly reduce the number of original records
Reply

Use magic Report

0

Threads

22

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-7-25 22:45:01
| Show all posts
-Find out the earliest inserted record in each type
(select Code,min(rowid) rid from A group by Code)
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list