I have the following query within inside a select if
in my code and I can't remember what the line containing @lastComment := time
actually does?
SELECT
IF(
(SELECT @lastComment := `time`
FROM usermessages
WHERE userId = $userId
ORDER BY id DESC
LIMIT 1)
IS NOT NULL,
DATE_SUB(NOW(), INTERVAL 30 SECOND) >= @lastComment, 1
)
It looks like @lastComment is just a temporary variable holding time but I don't understand why it's needed, is it just to pass it to the other query?