作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想创建一行来删除特定 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/
我是一名优秀的程序员,十分优秀!