开发者

Update statement SQL to increment date by 365 days

开发者 https://www.devze.com 2023-01-25 08:19 出处:网络
I have two columns in my mysql db, end_date (example 9999-12-31) and start_date (example 2010-11-17), of type \"DATE\".

I have two columns in my mysql db, end_date (example 9999-12-31) and start_date (example 2010-11-17), of type "DATE".

I want to do an update statement on the table such that if end_date = 9999-12-31, It will change the end_date to start_date + 365 days. But I only wan开发者_如何学Got it do update if end_date is 9999-12-31 (which essentially means no end date has been set)


UPDATE sometable
SET end_date=DATE_ADD(start_date, INTERVAL 365 DAY)
WHERE end_date='9999-12-31'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号