add specific line in Mysql

0

Talk about the person!

I am inserting a time (hour: minutes: seconds) into an x column, would you like to know if it is possible to add the current value of the line with the next value that is entered? as if it were a + =. For example: One line of the IDx of the Time column, it receives a value of 01:00:00 and then receives the value of 20 minutes, that is, 01:20:00. do this without the need to do a query on the line and add with the new value and then do an update. Thank you.

The table is as follows:

# nomeID       situação      tempo    tTotal

127.0.0.1       Disponi    00:00:10  00:00:00
192.168.1.102   Ocupada    00:00:00  00:00:00
192.168.1.103   Disponi    01:26:00  01:26:00
192.168.1.104   Ocupada    00:00:00  00:00:00    
    
asked by anonymous 10.08.2016 / 22:10

1 answer

1

Let's say that the new value to be added is 20 min -> 00:20:00 and the id is 1, then it would look like this:

UPDATE tabela
SET tTempo = SEC_TO_TIME( TIME_TO_SEC(tTempo) + TIME_TO_SEC('00:20:00') )
WHERE id = '1'
    
10.08.2016 / 22:42