我希望在MySQL中编写一个查询,它可以提供过去30天内的结果。有一个名为start_date的字段,它处于unixtime中,我需要说出如下内容:
SELECT *
FROM employees
WHERE (start_date) is within the past 30 days
我如何为此编写WHERE子句?
答案 0 :(得分:0)
您可以在
之间使用SELECT *
FROM employees
WHERE start_date BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
答案 1 :(得分:0)
使用from_unixtime
转换unixtime列进行比较。
SELECT *
from employees
where from_unixtime(start_date) between now() - interval 30 day and now()