Home > Software engineering >  Automatically add days to a column based on other table columns
Automatically add days to a column based on other table columns

Time:07-26

I have a table A which has column NoOfDays, and another table B which has a column MyDate of type datetime and it is set to Default as "CURRENT_TIMESTAMP". Now in table B, I want to add a new column (called ValidDate), which should AUTOMATICALLY store the sum value of (B.MyDate A.NoOfDays)

For example, if B.MyDate has value of "2022-07-25 04:50:26" and A.NoOfDays has value of "60", then B.ValidDate should get the value of "2022-09-23 04:50:26"

What is the way in MySQL to set this new column value to store this summed value automatically.

Checked for existing threads, but found only this one which does not offer a solution to store, but to create a view output only. Click to see image

  • Related