@@ -34,6 +34,7 @@ image::n1ql-language-reference/select-clause.png["Syntax diagram", align=left]
3434[horizontal.compact]
3535hint-comment:: <<hint-comment>> icon:caret-down[]
3636projection:: <<sec_Arguments>> icon:caret-down[]
37+ exclude-clause:: <<sec_ExcludeClause>> icon:caret-down[]
3738
3839[#hint-comment]
3940=== Optimizer Hints
@@ -155,6 +156,47 @@ If you do not explicitly give a field an alias, it is given an _implicit alias_.
155156
156157An implicit or explicit alias is returned in the result set, unless you suppress it using the <<raw-element-value,RAW keyword>>.
157158
159+ [#sec_ExcludeClause]
160+ === EXCLUDE Clause
161+
162+ [source,ebnf]
163+ ----
164+ include::partial$grammar/dql.ebnf[tag=exclude-clause]
165+ ----
166+ image::n1ql-language-reference/exclude-clause.png["Syntax diagram", align=left]
167+
168+ The EXCLUDE clause removes specific fields from your query's result set.
169+
170+ Instead of listing every field you want to include in the SELECT statement, use EXCLUDE to specify only the ones you want to omit.
171+ This is particularly useful when you use the star expression (`{asterisk}`) to select all fields, but want to exclude a few.
172+
173+ The clause consists of one or more <<exclude-term, EXCLUDE terms>>, separated by commas.
174+
175+ [[exclude-term]]
176+ ==== EXCLUDE Term
177+ [source,ebnf]
178+ ----
179+ include::partial$grammar/dql.ebnf[tag=exclude-term]
180+ ----
181+ image::n1ql-language-reference/exclude-term.png["Syntax diagram", align=left]
182+
183+ An EXCLUDE term is a field that you want to exclude from the final projection.
184+ It must exactly match the field name or alias as it appears in the projection.
185+ Refer to <<ex-exclude-clause>>.
186+
187+ An EXCLUDE term can be:
188+
189+ * An identifier, such as `hotel.name`.
190+ * A string expression with one or more fields separated by commas, such as `"hotel.name, address"`.
191+
192+ [NOTE]
193+ ====
194+ * If the field has an alias, you must use the alias as the term.
195+ * When your query includes only one FROM term, fields are automatically qualified with it.
196+ You can use the field name without the full identifier.
197+ For example, `name` instead of `hotel.name`.
198+ ====
199+
158200[#sec_BestPractices]
159201== Best Practices
160202
@@ -632,6 +674,52 @@ FROM hotel LIMIT 5;
632674<.> With a select expression, you may optionally include the keyspace name; in either case, the keyspace name is not added to the results.
633675====
634676
677+ [[ex-exclude-clause]]
678+ .SELECT with an EXCLUDE clause
679+ ====
680+ .Query
681+ [source,sqlpp]
682+ ----
683+ SELECT * EXCLUDE reviews,h.public_likes,"geo,description"
684+ FROM `travel-sample`.inventory.hotel h
685+ ORDER BY meta().id LIMIT 1;
686+ ----
687+
688+ .Results
689+ [source,json]
690+ ----
691+ [
692+ {
693+ "h": {
694+ "address": "Capstone Road, ME7 3JE",
695+ "alias": null,
696+ "checkin": null,
697+ "checkout": null,
698+ "city": "Medway",
699+ "country": "United Kingdom",
700+ "directions": null,
701+ "email": null,
702+ "fax": null,
703+ "free_breakfast": true,
704+ "free_internet": false,
705+ "free_parking": true,
706+ "id": 10025,
707+ "name": "Medway Youth Hostel",
708+ "pets_ok": true,
709+ "phone": "+44 870 770 5964",
710+ "price": null,
711+ "state": null,
712+ "title": "Gillingham (Kent)",
713+ "tollfree": null,
714+ "type": "hotel",
715+ "url": "http://www.yha.org.uk",
716+ "vacancy": true
717+ }
718+ }
719+ ]
720+ ----
721+ ====
722+
635723[#sec_RelatedLinks]
636724== Related Links
637725
0 commit comments