例如,我有一个简单的SQL:

select product.name from products;

在我的桌子上有两种产品:方向盘,方向盘。
所以我的结果是:
wheel
steering wheel

如果结果超过一个单词,如何获取引用的结果?:
wheel
"steering wheel"

我试图使用quote_literal函数,但结果总是被引用。
quote_literal的工作方式就像我只需要常量字符串,比如:quoted_literal('steering wheel')/quoted_literal('wheel')

最佳答案

怎么办:

SELECT CASE WHEN (product.name LIKE '% %')
THEN quoted_ident(product.name) ELSE product.name END
FROM products;

10-07 19:08
查看更多