UPDATE mytable SET average_play_time =
(SELECT ifnull( SEC_TO_TIME(avg(timestampdiff(SECOND, start_time, end_time))), '00:30:00') as average_play_time
FROM
my_second_table WHERE venue=32 AND start_time > '2018-01-01 14:00:00' )
WHERE id=32;
I also tried:
UPDATE mytable SET average_play_time =
(SELECT IF( SEC_TO_TIME(avg(timestampdiff(SECOND, start_time, end_time))) IS NULL, '00:30:00', SEC_TO_TIME(avg(timestampdiff(SECOND, start_time, end_time))) ) as average_play_time
FROM
my_second_table WHERE venue=32 AND start_time > '2018-01-01 14:00:00' )
WHERE id=32;
But if I run only the select query, it returns the value correctly. And it works if select returns records/value from table, but not '00:30:00' value if there is no records.