Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

JSON returns subdocuments and arrays in JSON format.

Example

Code Block
SELECT JSON * 
   FROM zips 
   WHERE city LIKE 'H%' 

Back to top

FLATTEN_ARRAY

FLATTEN_ARRAY flattens subdocuments and unfurls array values.  Each subfield in a subdocument is returned as a separate field.  Each value in an array is returned in a separate record with any non-array fields being duplicated.

Example



Code Block
SELECT FLATTEN_ARRAY * 
   FROM zips 
   WHERE city LIKE 'H%' 



Back to top

DISTINCT | ALL option

...

The DISTINCT keyword returns only distinct (different) values. DISTINCT only supports querying one field based on MongoDB's specifications.

Example



Code Block
SELECT DISTINCT state 
   FROM zips


Info

MongoDB flattens an array field when processing the DISTINCT command.

Info

The following DISTINCT select statements are not supported. They will generate an error.

SELECT DISTINCT * FROM zips
GO

SELECT DISTINCT city, state, pop FROM zips
GO



Back to top

ALL

ALL is default. Returns all values.

...