[英]Converting timestamp from one column of an SQL table to dates in another column of the same table
I'd like to convert unix timestamps from one column of an existing sql table to dates in another column of the same table.我想将 unix 时间戳从现有 sql 表的一列转换为同一表的另一列中的日期。 Something like this: take the values of column TIMESTAMP from every raw and convert it into a date and put it into column DATE.
像这样:从每个原始数据中获取列 TIMESTAMP 的值并将其转换为日期并将其放入列 DATE。
I already figure out that the below expression converts the timestamps into dates:我已经发现下面的表达式将时间戳转换为日期:
SELECT FROM_UNIXTIME(TIMESTAMP) FROM MYTABLE
but I don't know how to plug this into a normal sql update expression.但我不知道如何将其插入普通的 sql 更新表达式中。
Thanks for any advice!感谢您的任何建议!
W宽
Use the expression in the SET
clause of the UPDATE
query.在
UPDATE
查询的SET
子句中使用表达式。
UPDATE MYTABLE
SET date = FROM_UNIXTIME(timestamp)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.