本文介绍了按日期选择条目 - > = NOW(),MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个活动日历表,我想选择日期等于或大于今天的事件。当我使用以下SELECT语句时,它仅在以后检索事件(> NOW()):
I have a Calendar of Events table and I would like to select events with dates equal to or greater than today. When I use the following SELECT statement, it only retrieves events in the future (> NOW()):
<?php
$db->query("SELECT * FROM events WHERE event_date >= NOW()");
?>
我将如何选择今天或将来的所有活动?
How would I go about selecting all events that are either today or in the future?
谢谢
推荐答案
您正在寻找:
You are looking for CURDATE()
:
$db->query("SELECT * FROM events WHERE event_date >= CURDATE()");
或:
$db->query("SELECT * FROM events WHERE event_date >= CURRENT_DATE()");
这篇关于按日期选择条目 - > = NOW(),MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!