如何将函数的空行返回值转换为mysql中的空表?

时间:2022-01-10 00:47:05

I have a function that returns a string or NULL. In order to get an empty table instead of an empty row I did the following:

我有一个返回字符串或NULL的函数。为了获得一个空表而不是一个空行,我做了以下事情:

SELECT destination
FROM (
  SELECT dynamicAlias(
    'teststring'
  ) AS destination
) AS d2
WHERE destination IS NOT NULL
LIMIT 1

Is there a better way? I can change dynamicAlias() to return an empty string if this helps.

有没有更好的办法?我可以更改dynamicAlias()以返回空字符串,如果这有帮助的话。

1 个解决方案

#1


0  

What about:

SELECT dynamicAlias(
    'teststring'
  ) AS destination
HAVING destination IS NOT NULL
LIMIT 1

#1


0  

What about:

SELECT dynamicAlias(
    'teststring'
  ) AS destination
HAVING destination IS NOT NULL
LIMIT 1