1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > mysql高级查询(一) mysql如何查询时间间隔大于5分钟的数据时间从现在往前推 – 数

mysql高级查询(一) mysql如何查询时间间隔大于5分钟的数据时间从现在往前推 – 数

时间:2019-08-06 11:51:14

相关推荐

mysql高级查询(一) mysql如何查询时间间隔大于5分钟的数据时间从现在往前推 – 数

;declare thisname varchar(10)

;declare done tinyint default 0;declare cur cursor for select dtime,name from `table`

;declare continue handler for sqlstate 2000 set done=1;create temporary table if not exists `tmp`(dtime datetime, name varchar(10));while done1 doif lastdtime is null thenfetch cur into lastdtime,lastname;elsefetch cur into thisdtime,thisname;if timediff(thisdtime,lastdtime)>0:05:00 theninsert into `tmp` (dtime,name)values(lastdtime,lastname)

;set lastdtime=thisdtime;set lastname=thisname;end if;end if;end while;select * from `tmp`;End//call findtime()//

mysql高级查询(一) mysql如何查询时间间隔大于5分钟的数据时间从现在往前推 – 数据库 – 前端 mysql 表 的host

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。