我正在运行以下MySQL脚本,它会抛出错误,有人能告诉我出了什么问题吗?
"ALTER TABLE class_sessions_archive MODIFY COLUMN session_time_computed int(11) AS TIME_TO_SEC(ends_on-starts_on)"
MySQL中的错误消息仍然含糊不清,但是,我将其粘贴到此处:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TIME_TO_SEC(ends_on-starts_on)' at line 1
我所需要的只是取两个日期的差异,并在一个新列中以秒为单位存储它。我创建了一个新列,现在想要修改它。
答案 0 :(得分:0)
表达式应放在括号中:
ALTER TABLE class_sessions_archive
MODIFY COLUMN session_time_computed int(11) AS (TIME_TO_SEC(ends_on - starts_on));