mysql - When I run TIME_TO_SEC to modify a GENERATED column, it throws an error although TIME_TO_SEC works fine independently in a SELECT statement -


i running following mysql script , throws error, tell me wrong?

"alter table class_sessions_archive modify column session_time_computed int(11) time_to_sec(ends_on-starts_on)" 

the error message in mysql remains cryptic, however, paste here:

you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'time_to_sec(ends_on-starts_on)' @ line 1  

all need take difference of 2 dates , store in seconds in new column. made new column , want modify it.

the expression should go in parentheses:

alter table class_sessions_archive     modify column session_time_computed int(11) (time_to_sec(ends_on - starts_on)); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -