MySQL根据每日时间戳范围进行选择 [英] MySQL select based on daily timestamp range
本文介绍了MySQL根据每日时间戳范围进行选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图根据时间戳(存储为int(10))从表中选择数据.时间戳对应于unix时间戳.我正在使用MySQL 5.
I am trying to select data from a table based on timestamps (stored as int(10)). The timestamps correspond to unix timestamps. I am using MySQL 5.
问题:如何根据以下规则选择数据:获取所有记录,时间戳为9点至10点.没有其他的.时间戳记可能在70年代或今天.
Question: How can I select the data based on the following rule: get all records, where the timestamp is from 9 to 10 o'clock. Nothing else. Timestamp could be in the 70's or today.
推荐答案
如果将值存储为UNIX时间戳,则需要在使用HOUR函数之前将值转换为MySQL的时间戳格式.
If you're storing the value as a UNIX timestamp, you'll need to convert the value into MySQL's timestamp format before using the HOUR function.
WHERE HOUR(FROM_UNIXTIME(`timestamp`)) = 9
这篇关于MySQL根据每日时间戳范围进行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文