0

我的桌子

id_street | main_name | feature | name | gus_compatible |
----------+-----------+---------+------+----------------+
38454     | woods     | alley   |      | t              |
----------+-----------+---------+------+----------------+
38455     | hills     |         |      | t              |

我的查询

SELECT id_street, feature || ' ' || main_name AS street FROM streets ORDER BY main_name DESC

在我的数据输出中,我会看到街道alley woods,但不会有hills。为什么会这样?

4

1 回答 1

2

postgresql 中任何 NULL 值的连接都将返回 NULL。这是设计使然。您需要使用 COALESCE(feature,'') 将 NULL 值转换为空字符串,以便在连接中不使用 NULL 值。

于 2013-10-30T17:21:28.550 回答