【发布时间】:2018-12-17 12:48:44
【问题描述】:
我开发了这个解决方案,如果有其他更好的解决方案,请分享。
SET @num = (SELECT count(distinct(detalle)) as 'distintos'
FROM
(SELECT detalle, SUBSTRING(momento, 1, 10) as momento FROM t2
where detalle in ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I')) AS T1
where momento like (Select SUBSTRING(momento, 1, 10) as momento from t2 order by momento desc limit 1));
INSERT INTO `t2`.`log_reportes` (`accion`, `detalle`)
SELECT 'REVISION AUTOMATICA', 'ERROR' FROM DUAL
WHERE @num = 6;
INSERT INTO `t2`.`log_reportes` (`accion`, `detalle`)
SELECT 'REVISION AUTOMATICA', 'OK' FROM DUAL
WHERE @num = 7;
【问题讨论】:
-
更好的解决方案是什么?你还没有告诉我们你想做什么。
-
几乎总有比
@num等许多神秘变量更好的解决方案。
标签: mysql sql if-statement conditional