开发者

Update statement SQL to increment date by 365 days

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜