couchbase SELECT QUERY 语法
couchbase SELECT QUERY Syn
我插入了用户文档。当我 运行 SELECT 查询时:SELECT * FROM my_buckt WHERE type = “user”
我可以看到如下图的结果。
[{
"my_buckt": {
"createdTs": xxxxx,
"createdBy": "xxxx",
"data": {
"title": test
},
"type": "user",
"uuid": "xxxxxxxxx"
}
}]
但是当我尝试 运行 下面的查询时,它给出了一个错误。我只是在存储桶名称后添加了类型。请告知我遗漏了什么,以使其适用于以下 SELECT 查询:
SELECT * FROM my_buckt user WHERE type = “user”
“code”: 3000, “msg”: “syntax error - at user”,
这是因为 user
是保留字(有关保留字的完整列表,请参阅 documentation)。所以要么你可以使用别的东西作为别名,像这样:
SELECT * FROM my_buckt u WHERE type = "user"
或者你可以在用户周围加上反引号,像这样:
SELECT * FROM my_buckt `user` WHERE type = "user"
我插入了用户文档。当我 运行 SELECT 查询时:SELECT * FROM my_buckt WHERE type = “user”
我可以看到如下图的结果。
[{
"my_buckt": {
"createdTs": xxxxx,
"createdBy": "xxxx",
"data": {
"title": test
},
"type": "user",
"uuid": "xxxxxxxxx"
}
}]
但是当我尝试 运行 下面的查询时,它给出了一个错误。我只是在存储桶名称后添加了类型。请告知我遗漏了什么,以使其适用于以下 SELECT 查询:
SELECT * FROM my_buckt user WHERE type = “user”
“code”: 3000, “msg”: “syntax error - at user”,
这是因为 user
是保留字(有关保留字的完整列表,请参阅 documentation)。所以要么你可以使用别的东西作为别名,像这样:
SELECT * FROM my_buckt u WHERE type = "user"
或者你可以在用户周围加上反引号,像这样:
SELECT * FROM my_buckt `user` WHERE type = "user"