Getting past mysql database record

0

I have two tables, I want to get the previous record of the recorded data from the second table based on the first one.

  Tabela 1      |        Tabela 2
 id - hora    |  id - id_tabela1 - cod
 1    02:30   |   1        1         1
 2    02:45   |   2        2         3
 3    03:00   |   3        3         1

What he wanted was to take the time difference between codes. ex.

    diferenca
   cod - hora
    1    00:00
    3    00:00
    1    00:30

Does anyone know what the MySQL query would look like?

    
asked by anonymous 28.09.2016 / 19:39

1 answer

0

I've already decided, instead of getting the difference in the query I'm doing at the time of inserting the elements using timediff (time1, hour2)

timediff(curtime(), t1.hora)
    
28.09.2016 / 21:20