Reputation: 23
I need to update and add one day all dates currently I have in the bse data, the table is carts and it ocurred only for rows with choi_id = 1030;
CARTS - id - name - choi_id; - inserted
I tried for:
UPDATE carts SET inserted = inserted + 1 where choi_id = 1030;
Upvotes: 2
Views: 128
Reputation: 31
UPDATE carts
SET `inserted` = DATE_ADD(`inserted` , INTERVAL 1 DAY)
WHERE `choi_id` = 1030;
This works. MySQL data types exist, you can not treat a datetime as a number.
Upvotes: 0
Reputation: 390
You could try this:
UPDATE carts
SET `inserted` = DATE_ADD(`inserted` , INTERVAL 1 DAY)
WHERE `choi_id` = 1030;
The DATE_ADD MySQL function adds a specified time interval to a date, seconds, minutes, months, years, etc... Your input is a datetime field, not a integer then +1 not working for that.
See here the doc: DATE_ADD
Upvotes: 2
Reputation: 64476
You can do so
UPDATE carts
SET inserted = inserted + INTERVAL 1 DAY
where choi_id = 1030;
Upvotes: 1