如何在现有列中添加值?

ijnw1ujt  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(338)

我有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

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题