dip s

dip s

  • NA
  • 256
  • 81.8k

Set Value of a GENERATED column in a table with if condition in MYSQL

Dec 11 2020 1:02 AM
I have two columns named 'FromTime' and 'ToTime' in a Table.
I have set 'ToTime' column as Generated coulmn.
Now, I want to write an expression for this 'ToTime' column.
What I want to do is,
 
If 'ToTime ' is not provided while saving data to this table then it should save FromTime's value to 'ToTime' column.
 
If 'ToTime' is provided while saving data into the table then ToTime's value should be saved  to 'ToTime' Column. 
 
 
How to write this condition/expression for saving data into generated column in MYSQL.
Thank you in advance. 
 

Answers (3)