【问题标题】:SQL query where time < time nowSQL 查询 where time < time now
【发布时间】:2023-03-25 05:52:01
【问题描述】:

我有一个关于 SQL 查询的问题。我在数据库中有一行称为starting_time(时间戳)。我想从表中选择开始时间在未来的每一行(稍后是现在的时间)。

我尝试了以下查询,但这不起作用。 (我知道 mysql 函数而不是 mysqli)。

$lsel_select = mysql_query("select * from table WHERE startingtime < $time(now) order by id desc");
while ($select = mysql_fetch_array($lsel_lijst)) { 

【问题讨论】:

    标签: php mysql sql timestamp


    【解决方案1】:

    MySQL 函数NOW() 返回当前时间。所以比较一下吧。

    WHERE starting_time > NOW()
    

    既然你想要未来的时间,而不是过去,你应该使用&gt;,而不是&lt;

    【讨论】:

    • 他说“starting_time 在未来的哪个位置”
    【解决方案2】:

    试试这个"select * from table WHERE startingtime &lt; NOW() order by id desc"

    【讨论】:

      【解决方案3】:

      试试这个:

      $lsel_select = mysql_query("select * from table WHERE startingtime

      如果有帮助别忘了采纳

      【讨论】:

        猜你喜欢
        • 2011-06-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-07-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多