SQL++ - User Friendly Language

If you're' familiar with standard SQL, then picking up N1QL will be easy.

A simple query in N1QL has three parts to it:
    SELECT — Parts of document to return
    FROM — The data bucket, or data store to work with
    WHERE— Conditions the document must satisfy

Only a SELECT clause is required in a query. The wildcard * selects all top-level fields of the document. Queries can return a collection of different document structures or fragments, however they will all match the conditions in the WHERE clause.

Remember that there is no schema in Couchbase. N1QL is flexible enough to return all results that match your query, even if they vary in structure.

If you change the * to a document field such as “children” you will see the query return a collection of appropriate fragments of each document.

Try the next sample query where we find all documents where the name is 'Ian'.

To run this example, click the button in the top right corner of the code editor.

Code Editor