Använd timestampdiff
funktion för det och CASE
:
select case
when TIMESTAMPDIFF(SECOND, `date`,current_timestamp) <= 60
then concat(TIMESTAMPDIFF(SECOND, `date`,current_timestamp), ' seconds')
when TIMESTAMPDIFF(DAY, `date`,current_timestamp) <= 3
and TIMESTAMPDIFF(DAY, `date`,current_timestamp) >= 1
...
end as time_diff
from Table_hello
where TIMESTAMPDIFF(DAY, `time`,current_timestamp) >= 3