我有像打击代码这样的时间字符串,现在我想不时比较一下时间,如果持续时间超过15分钟,我将更新表格中的一个字段
CREATE DEFINER=`root`@`localhost` PROCEDURE `EXPIRESESSION`()
wholeblock:BEGIN
declare str VARCHAR(900) default '';
SET str='2019-06-13 09:56:44,2019-06-13 13:49:46,';
WHILE (LOCATE(',', str) > 0)
DO
SET @value = ELT(1, str);
SET str= SUBSTRING(str, LOCATE(',',str) + 1);
SET @duration=(SELECT TIMESTAMPDIFF(MINUTE, (SELECT B.logtime FROM users B WHERE B.logtime IS NOT NULL), NOW()));
IF(@duration>15) THEN
UPDATE users SET logtime =null where logtime = str;
END IF;
END WHILE;
END