我有这个查询:
SELECT
COALESCE(CONCAT(Ar.usaf, '-', Ar.wban),"NONE") AS TABLE_NAME
FROM
`metadata`.`ISH-HISTORY_HASPOS` A
INNER JOIN `metadata`.`Artificial` Ar ON (Ar.id = A.mergeId)
WHERE
A.usaf = usaf
AND A.wban = wban;
当没有发生连接并且结果为 NULL 时,我希望查询用“NONE”来合并 null 结果,但是我仍然得到 NULL。我将如何使它返回“NONE”而不是 NULL?
我忽略了解释一个重要的点:
usaf
并且wban
是IN
a 的变量stored procedure
。这是我的最终(工作)版本。谢谢罗兰多
BEGIN
SET @usaf = usaf;
SET @wban = wban;
SELECT
COALESCE(CONCAT(Ar.usaf, '-', Ar.wban),"NONE") AS TABLE_NAME
FROM
`metadata`.`ISH-HISTORY_HASPOS` A
INNER JOIN `metadata`.`Artificial` Ar ON (Ar.id = A.mergeId AND A.usaf = @usaf AND A.wban = @wban)
LIMIT 1;
END