Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在mysql中搜索时间_Php_Mysql_Sql_Date - Fatal编程技术网

Php 在mysql中搜索时间

Php 在mysql中搜索时间,php,mysql,sql,date,Php,Mysql,Sql,Date,这是我的桌子: +------------+--------------+---------------------+--------+ | id | playduration | time | id_his | +------------+--------------+---------------------+--------+ | 129 | 00:00:00 | 2014-01-19 04:08:00 | 1

这是我的桌子:

+------------+--------------+---------------------+--------+
| id         | playduration | time                | id_his |
+------------+--------------+---------------------+--------+
|        129 | 00:00:00     | 2014-01-19 04:08:00 |      1 |
|        190 | NULL         | 2014-01-19 02:20:34 |      6 |
| 1390228962 | NULL         | 2014-01-19 02:09:20 |      4 |
| 1390228963 | NULL         | 2014-01-19 02:06:12 |      3 |
|        188 | NULL         | 2014-01-19 02:00:11 |      5 |
|        151 | NULL         | 2014-01-19 01:06:01 |      7 |
|        195 | NULL         | 2014-01-15 01:10:00 |      2 |
+------------+--------------+---------------------+--------+
当我搜索time=2014-01-19 02:07:00时,我想得到row id=1390228963
我想我已经被解释好了

只要使用这个mysql查询就可以了


从tablename中选择*,其中时间=2014-01-19 02:00:11

您需要在时间之前获取最后一行:

select t.*
from table t
where time <= '2014-01-19 02:07:00'
order by time desc
limit 1;

但是我没有那个时间的记录,如果你没有时间列,你就不能查询那个记录。是的,我现在要这个,但是我想在这个之前得到这个记录time@OussamaTn然后只需使用:从tablename中选择id,其中时间<'2014-01-19 02:00:11'按时间描述限制1排序;