Reputation:
I have this in my DB:
| id | time | time-left |
| 1 | 242363246 | 1 |
| 2 | 215625252 | 1 |
| 3 | 147852369 | 1 |
| 4 | 951753456 | 1 |
How can I insert into time-left
the same as in time
but with 111 more? Here is how I want it to become:
| id | time | time-left |
| 1 | 242363246 | 242363357 |
| 2 | 215625252 | 215625363 |
| 3 | 147852369 | 147852480 |
| 4 | 951753456 | 951753567 |
Upvotes: 0
Views: 34
Reputation: 44881
Assuming time
is an integer or a char type that can be incremented (with implicit conversion):
UPDATE your_table
SET "time-left" = time + 111;
If time
can't be incremented this way you have to cast/convert it to an integer type first.
Depending on what DBMS you are using the way to use quoted identifiers for invalid names (like time-left
in this case) might be something else like using brackets: [time-left]
(SQL Server) or using backticks: `time-left`
(MySQL).
Upvotes: 2