我有3列:( ToDate
, FromDate
, Diff
) .
我想自动添加一个值到 Diff
之间有差异的列 ToDate
以及 FromDate
,并希望将其保存到表中。
我可以手动创建临时 Diff
列使用 SELECT ToDate,FromDate, (TO_DAYS(FromDate) - TO_DAYS(ToDate)) AS Diff FROM tbl_name
,
但不会保存到 Diff
柱
所以我最后键入: INSERT INTO tbl_name (Diff) SELECT (TO_DAYS(FromDate) - TO_DAYS(ToDate)) AS Diff FROM tbl_name
我想要这样的东西:
FromDate
2018-05-22
ToDate
2018-05-23
Diff
1
暂无答案!
目前还没有任何答案,快来回答吧!