在具有如下结构的数据库表中:
表1
Name | Id
A 1
B 2表2
Table1's ID | IntValue
1 11
2 66现在,有一个连接这两个表的查询,并输出类似于
A | 11
B | 66但问题是,假设从table1中删除了行(A,1),查询将输出
| 11
B | 66因此,不是写A,而是将其保留为null,因为该行不存在。
我的问题是:有没有什么方法可以让它写成"Item Inexistent“或”smth“,而不是把它留为null?
我的数据库是Firebird 2.1.2
发布于 2009-08-04 14:41:18
SELECT COALESCE(t1.name, 'Item nonexistent'), t2.intValue
FROM table2 t2
LEFT OUTER JOIN
table1 t1
ON t1.id = t2.idhttps://stackoverflow.com/questions/1227907
复制相似问题