n1ql中是否有一个类似于mysql串联的函数,它允许我连接两个字段,例如:
select
firstName + " " + lastName
from table
答案 0 :(得分:2)
N1QL提供连接字符串运算符。结果 连接运算符也是一个字符串。
expression || expression The following example shows concatenation of two strings.
<强>查询:强>
SELECT fname || " " || lname AS full_name FROM tutorial
<强>结果:强>
{ "results": [ { "full_name": "Dave Smith" }, { "full_name": "Earl Johnson" }, { "full_name": "Fred Jackson" }, { "full_name": "Harry Jackson" }, { "full_name": "Ian Taylor" }, { "full_name": "Jane Edwards" } ] }
答案 1 :(得分:0)
如果要串联,Integers
应该首先用TO_STRING
进行转换:
SELECT 'My name is ' || fname || ' and my age is ' || TO_STRING(30) || ' years old' AS age
FROM app
{
"results": [
{
"age": "My name is Dave and my age is 30 years old"
},
{
"age": "My name is Earl and my age is 30 years old"
},
{
"age": "My name is Fred and my age is 30 years old"
},
{
"age": "My name is Harry and my age is 30 years old"
},
{
"age": "My name is Ian and my age is 30 years old"
},
{
"age": "My name is Jane and my age is 30 years old"
}
]
}