I have following code:
SELECT *
FROM tier
WHERE
TIMESTAMPDIFF( HOUR, now(), FROM_UNIXTIME(expireAt) ) < 72
AND TIMESTAMPDIFF( HOUR, now(), FROM_UNIXTIME(expireAt) ) > 0
You can see, that there is a TIMESTAMPDIFF calculation twice.
Is there any way how to perform this calculation only once?
You can use
between. Sincebetweenincludes range boundaries, instead of 0 and 72 you need to use 1 and 71.