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排序;