我的命令在 mysql Ver 8.0.21 for Linux on x86_64(源代码分发)中运行,并且相同的命令在 mysql Ver 14.14 Distrib 5.6.51 中运行,对于使用 EditLine 包装器的 Linux(x86_64)。我收到语法错误。
WITH difference_in_seconds AS (
SELECT
incident,
description,
status,
incident_start,
now(),
TIMESTAMPDIFF(SECOND, incident_start, now()) AS seconds
FROM incidents where description like '%MSK%' AND status='acknowledged' AND description not like '%TEST%'
),
differences AS (
SELECT
incident,
description,
status,
incident_start,
seconds,
MOD(seconds, 60) AS seconds_part,
MOD(seconds, 3600) AS minutes_part,
MOD(seconds, 3600 * 24) AS hours_part
FROM difference_in_seconds
)
SELECT
incident,
status,
CONCAT(
FLOOR(seconds / 3600 / 24), ' days ',
FLOOR(hours_part / 3600), ' hours ',
FLOOR(minutes_part / 60), ' minutes ',
seconds_part, ' seconds'
) AS difference,
description,
incident_start,
now()
FROM differences;
错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 2 行的 'difference_in_seconds AS ( SELECT event, description, status, ' 附近使用正确的语法