我想在MySQL中显示最新的最长一小时记录我的表中有以下列id,value1,value2,date,date_time记录是
id value1 value2 date date_time
21 12 10 2015-01-21 2015-01-21 01:23:43
21 7 4 2015-01-21 2015-01-21 01:29:32
21 5 3 2015-01-21 2015-01-21 13:25:54
21 8 13 2015-01-21 2015-01-21 13:45:21
21 8 78 2015-01-21 2015-01-21 02:23:25
21 3 7 2015-01-21 2015-01-21 02:43:25
从上面的记录我想显示记录3-4,记录最多有一小时(13)记录请给我指导,以显示最多一小时的记录
答案 0 :(得分:1)
所以
select * from your_table where hour(date_time) in (select hour(max(date_time)) from your_table)
答案 1 :(得分:0)
从your_table中选择*,其中current_timestamp - interval 1 hour和current_timestamp
之间的convert(date_time,datetime)答案 2 :(得分:0)
怎么样:
select * from
( select * from table order by date_time desc ) as q0
where timediff( now(), date_time ) < "00:01:00 000000";