I am trying to update a date column based on an existing date column by adding days/weeks/months to the existing date
update Form_1 set `DateP1`= DATE_ADD(`Date`, INTERVAL `P1` week) where
`id`=1;
This works perfectly, however what I am trying to achieve is something like this which does not seem to work
update Form_1 set `DateP1`= DATE_ADD(`Date`, INTERVAL `P1` `TimeType`) where
`id`=1;
Here, the TimeType is another column in my table and contains values like day, week, month... basically the time information. I want to be able to pull value from the column dynamically instead of
DATE_ADD(`Date`, INTERVAL `P1` week)
where week is static. Is there a way to achieve this. I am OK with using any other alternate method as long as I can dynamically pull the values from the TimeType table.
CASEexpression there to check the value of your column and then useDATE_ADD()based on the value