sql - 将时间戳与时间戳范围进行比较
问题描述
我在下一个查询中有 event_timestamp:
SELECT COUNT(id) = 0 as "isEmpty"
FROM status
WHERE id = 22
AND event_timestamp > user_timestamp
现在我不能使用 condition event_timestamp > user_timestamp
,因为user_timestamp
我有一系列时间戳。喜欢:
id start_user_timestamp end_user_timestamp
22 2021-05-02 11:23:59.02343 2021-05-04 21:43:39.02343
22 2021-06-01 13:23:59.02343 2021-06-04 13:43:59.02343
22 2021-07-01 23:43:59.02343 2021-07-04 23:43:59.02343
event_timestamp
检查大于开始/结束值的最佳方法是什么?
解决方案
使用 AND 条件比较两列
SELECT COUNT(id) = 0 as "isEmpty"
FROM status
WHERE id = 22
AND user_timestamp > start_user_timestamp
AND user_timestamp > end_user_timestamp
推荐阅读
- node.js - 如何清除 NodeJS 中的缓冲区
- vba - 在 VBA 中设置颜色
- java - 为什么 Log4j2 在 System.exit(1) 之前不记录
- python - 0砖金字塔建筑python的错误输出
- jenkins - 如何在groovy中使用findfiles仅获取文件而不是目录的所有路径
- c# - 如何将 app.config 文件添加到项目中
- html - 在 SVG 文件中添加文本区域(将名称放在 svg tshirt 上方)
- android - Android:用户在未完成帐户创建的情况下仍然可以登录
- django - Django REST Framework - XMLRenderer 修改我的简单 XML 响应
- c# - 模拟一个多功能实例