SQL在日期或时间使用where子句过滤时间戳

时间:2018-05-24 06:58:45

标签: php sql timestamp unix-timestamp

我正在使用此表,我正在尝试根据日期或基于月份 date_time_stamp 字段

过滤记录
+---------------+-----------------+
| name          | date_time_stamp |
+---------------+-----------------+
| John          |      1329828975 |
+---------------+-----------------+
| Ken           |      1428728929 |
+---------------+-----------------+
| Bennedict     |      1526758965 |
+---------------+-----------------+
| Lily          |      1725498952 |
+---------------+-----------------+

以下SQL只能从表中获取日期,月份和年份,但添加 WHERE day = 5 标记错误

SELECT us.lessons_ID,
us.from_timestamp,
us.users_LOGIN,
       DAY(FROM_UNIXTIME(us.from_timestamp)) as 'day',
       MONTH(FROM_UNIXTIME(us.from_timestamp))  as 'month',
        YEAR(FROM_UNIXTIME(us.from_timestamp))  as 'year'
   FROM users_to_lessons  us

所以我的问题是如何过滤此表中的记录是等于五月或六月等等或基于过滤或甚至基于月过滤,日和年

如果有人能给我一个线索,我会很高兴的

0 个答案:

没有答案