gpt4 book ai didi

sql - 仅在需要时从 SQL 查询结果中返回引用数据

转载 作者:行者123 更新时间:2023-11-29 13:28:13 26 4
gpt4 key购买 nike

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

select product.name from products;

在我的表中,我有 2 个产品:车轮、方向盘。

所以我的结果是:

wheel
steering wheel

如果结果超过 1 个单词,如何获取引用结果?:

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;

关于sql - 仅在需要时从 SQL 查询结果中返回引用数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29572432/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com