[英]SQL query where time < time now
I have a question about a SQL query. 我有一个关于SQL查询的问题。 I have a row in database which is called starting_time (timestamp).
我在数据库中有一行称为starting_time(时间戳)。 I would like to select every row from the table where the starting_time is in the future (later then the time now).
我想从将来的starting_time所在的表中选择每一行(然后是现在的时间)。
I tried the following query, but that doesn't work. 我尝试了以下查询,但这不起作用。 (I am aware of the mysql function instead of mysqli).
(我知道mysql函数而不是mysqli)。
$lsel_select = mysql_query("select * from table WHERE startingtime < $time(now) order by id desc");
while ($select = mysql_fetch_array($lsel_lijst)) {
The MySQL function NOW()
returns the current time. MySQL函数
NOW()
返回当前时间。 So compare with that. 因此与之比较。
WHERE starting_time > NOW()
Since you want times in the future, not the past, you should use >
, not <
. 由于您想要的是未来而不是过去的时间,因此应该使用
>
而不是<
。
试试这个"select * from table WHERE startingtime < NOW() order by id desc"
Try This one: 试试这个:
$lsel_select = mysql_query("select * from table WHERE startingtime < ".time()." order by id desc"); $ lsel_select = mysql_query(“从表WHERE起始时间<” .time()中选择*。“按ID desc排序”);
Dont forget to accept ans if it helps 如果有帮助,不要忘记接受答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.