Mysql
 sql >> Base de données >  >> RDS >> Mysql

Mysql :rechercher des lignes, où la différence d'horodatage est inférieure à x

essayez ceci :-

select t1.user, t1.date d1,t2.date d2 ,t1.date-t2.date
  from  (select @val:[email protected]+1 rowid,user,  date
           from mytable,(select @val:=0) a
       order by user,date) t1,

        (select @val1:[email protected]+1 rowid,user,  date
           from mytable,(select @val1:=1) b
       order by user,date) t2

 where t1.rowid = t2.rowid
   and t1.user = t2.user
   and t1.date-t2.date < 1300;

voir DEMO