这是我的表:
+------------+--------------+---------------------+--------+
| 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 |
+------------+--------------+---------------------+--------+
我希望在搜索id = 1390228963
时获得行time = 2014-01-19 02:07:00
我以为我已经解释得很好
答案 0 :(得分:2)
您需要在时间之前获得最后一行:
select t.*
from table t
where time <= '2014-01-19 02:07:00'
order by time desc
limit 1;
答案 1 :(得分:0)
只需使用此mysql查询
SELECT * from tablename where time="2014-01-19 02:00:11";