2.SELECT,FROM,WHERE

类似于标准SQL语句。和SQL语句一样,* 可以是具体的查询字段。

请记住,Couchbase没有模式。N1QL足够灵活,可以返回与查询匹配的所有结果,即使它们在结构上有所不同。

Query:

SELECT *
  FROM tutorial
    WHERE fname = 'Ian'

Result:

{
  "results": [
    {
      "tutorial": {
        "age": 56,
        "children": [
          {
            "age": 17,
            "fname": "Abama",
            "gender": "m"
          },
          {
            "age": 21,
            "fname": "Bebama",
            "gender": "m"
          }
        ],
        "email": "ian@gmail.com",
        "fname": "Ian",
        "hobbies": [
          "golf",
          "surfing"
        ],
        "lname": "Taylor",
        "relation": "cousin",
        "title": "Mr.",
        "type": "contact"
      }
    }
  ]
}

Last updated

Was this helpful?