简体   繁体   English

将时间戳从 SQL 表的一列转换为同一表另一列中的日期

[英]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.

相关问题 从同一表 sql 中的另一列中获取一个更大的列 - Get one larger column from another columns in same table sql SQL - 从一个表列到另一个表列的值 - SQL - values from one table column to another table column SQL - 将数据从一个表列复制到另一个表列 - SQL - copy data from one table column to another table column SQL从另一个表中的另一列更新一列 - SQL update one column from another column in another table 使用另一个表中的列更新一个表中的时间戳列 - Update timestamp column in one table using a column in another table 如何编写一个查询,在 sql 中连接同一个表并将一个表的列值与另一个表中的相同列进行比较 - How to write a query that joins same table in sql and compares the column values of one table with same column in another table SQL-将行从一个表复制到另一个表并同时更新目标表中的列 - SQL - Copy row from one table to another and update column in destination table at the same time 在SQL中将日期列从varchar转换为datetime格式之前,将一个表的记录复制到另一个表 - Copy records of one table to another before converting date column from varchar to datetime format in sql SQL复制数据从一列到另一个表指定列 - SQL copy data from one column to another table specified column SQL无法将同一列中的一列转换为另一列的简单SET - SQL not working for a simple SET of one column to another in the same table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM