我有一个名为expiry的列,它以时间戳格式保存项目的到期日期。
如何执行MySQL查询以仅选择有效期为2天的项目?
谢谢!
答案 0 :(得分:5)
SELECT * FROM table WHERE expiry BETWEEN(TODAY(), TODAY() + 2)
答案 1 :(得分:1)
select * from mytable
where expiry between now() and adddate(now(), INTERVAL 2 DAY);
答案 2 :(得分:1)
SELECT * FROM table WHERE DATEDIFF(expire, NOW()) <= 2;
答案 3 :(得分:0)
SELECT ...
WHERE expiry <= NOW()+"2 days";
答案 4 :(得分:0)
WHERE dateCol <= date_sub(now(), interval 2 day);