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'
精彩评论