如何在PHP中更改此MySQL查询,以仅显示数据库中名为OpenHouseDate的日期列为当前日期或前方的所有列表?
$sql_query = "SELECT * FROM listings ORDER BY RAND()";
答案 0 :(得分:2)
$sql_query = "SELECT * FROM listings where OpenHouseDate >= current_date ORDER BY RAND()";
答案 1 :(得分:1)
SELECT * FROM listings WHERE DATE(OpenHouseDate) = DATE(NOW()) ORDER BY RAND()
答案 2 :(得分:1)
如果OpenHouseDate属于“日期”类型,则可以使用以下内容:
$sql_query = "SELECT * FROM listings WHERE OpenHouseDate <= CURDATE();
如果OpenHouseDate属于'DateTime'类型,那么您可以使用以下内容:
$sql_query = "SELECT * FROM listings WHERE OpenHouseDate <= NOW();
如果OpenHouseDate属于'Integer'类型,那么您可以使用以下内容:
$sql_query = "SELECT * FROM listings WHERE OpenHouseDate <= UNIX_TIMESTAMP(NOW());