jarv Posted August 4, 2011 Share Posted August 4, 2011 hi, the following SQL: UPDATE `customer` SET `ServiceDate` = DATE_ADD('1900-01-01', INTERVAL 40812 DAY) updates all records in my table at the column ServiceDate with a date 40812 days after 1900-01-01 My problem is is that each of the values in the ServiceDate column are not 40812, they are all different. 40812, 40965, 40723 and so on... Please help Quote Link to comment https://forums.phpfreaks.com/topic/243827-update-database-based-on-different-values/ Share on other sites More sharing options...
kickstart Posted August 4, 2011 Share Posted August 4, 2011 Hi How do you know which number of days to add to which row? I would guess that you have them stored on a different table. If so you probably want to do a JOIN within the UPDATE statement. Something like:- UPDATE FROM customer AS c LEFT JOIN someOtherTable as s ON c.blah = s.blah SET c.ServiceDate` = DATE_ADD('1900-01-01', INTERVAL s.SomeDayCount DAY) All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/243827-update-database-based-on-different-values/#findComment-1251932 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.