Catching previous mysql database record

Asked

Viewed 58 times

0

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

  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 I wanted was to get the time difference between the codes. ex.

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

Does anyone know what this query would look like in Mysql?

  • 1

    I could not understand your doubt. Be clearer

1 answer

0

I have already decided, instead of picking the difference in the query I am doing when inserting the elements using timediff(hora1,hora2)

timediff(curtime(), t1.hora)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.