gpt4 book ai didi

mysql - 减去 MYSQL 时间戳固定的小时数,其中 ID 是某事

转载 作者:行者123 更新时间:2023-11-29 12:38:21 24 4
gpt4 key购买 nike

我想创建一行来删除特定 ID 的特定时间戳,我使用 MariaDB 但还不知道如何操作。

X = some hour maybe 2 hours
TIMESTAMP = name of the table
Y = user id

我想要的是这样的:

从 TIMESTAMP 中删除 X 个小时,其中 id 为 Y

my timestamp format is not date it's like = 1414254628
below is on same table.
timestamp = 1414254628
timestamp2 = 1413646379

希望得到帮助,谢谢!

对代码块感到抱歉,但我在发布此线程时出错,所以我必须使它们看起来像代码

最佳答案

如果我理解正确并且您将纪元时间存储在时间戳列中,您只需从中减去所需的秒数

SELECT timestamp - 3600 * 2 newtimestamp -- subtract two hours
FROM users
WHERE user_id = 1

这里是SQLFiddle 演示

<小时/>

...how do i actually update the value?

通过使用更新

UPDATE users
SET timestamp = timestamp - 3600 * 2
WHERE user_id = 1;

这里是SQLFiddle

关于mysql - 减去 MYSQL 时间戳固定的小时数,其中 ID 是某事,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26441784/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com