informix 14.10 如何 "select" returns 特定短语如 None 或空白而不是没有结果

informix 14.10 How to "select" returns a specific phrase such as None or blank instead of no result

我有这样的查询:

  select c1 , ( select d1 from table2 where dt) from table1 where  ct

但是如果在条件 dt 下没有 d1 我没有结果但是我有这样的结果:

--c1               d1
value1       NONE or  Blank
value 2      NONE or  Blank    
  .                .
  .                .

有人可以帮忙吗?

NVL 函数可用于 return 它的两个参数中的任何一个,具体取决于第一个参数的计算结果是否为 NULL。所以你的示例查询可以写成:

select c1 , NVL(( select d1 from table2 where dt), "NONE") from table1 where ct

两个参数的数据类型需要兼容,例如都是字符或都是数字。 可以在 https://www.ibm.com/support/knowledgecenter/SSGU8G_14.1.0/com.ibm.sqls.doc/ids_sqs_1445.htm

找到更多信息