Skip to main content

Select Syntax

The SELECT syntax is essentially a JSON representation of the MySQL SELECT syntax. See the MySQL documentation for more detailed information.

SELECT

The SELECT syntax is contained in a single JSON object.

PropertyValueNotes
distinctboolean, default falseIf true, only returns unique values
columnsresult columnsIf empty, returns all columns available from source
fromsourceSource being selected from
whereexpressionCondition for rows, where expression returns true
grouparray of expressionsUsed to group rows for aggregation functions
havingexpressionLike where, but can filter aggregation results
orderarray of order termsUsed to sort the results
limitexpressionLimit the number of rows returned
offsetexpressionOffset of the start of the rows

Result Columns

Specifies the column(s) to select.

All

Specifies all columns from the source. This is the same as the MySQL SELECT * syntax. This is the default if no value for the columns property is set.

PropertyValue
type"all"

Example

{ "type": "all" }

Array

Specifies column(s) as an array of result column objects. May be provided directly as a JSON array.

PropertyValue
type"array"
arrayarray of result column(s)

Example as JSON object:

{
 "type"  : "array",
 "array" : [ ... ]
}

Example as JSON array:

[ ... ]

Result Column

Specifies an expression and optional alias.

PropertyValue
eexpression
aliasstring (optional)

Source

A source is a SQL table (or virtual table) from which a SELECT statement loads data.

Table Source

A source from any table.

PropertyValue
type"table"
tablestring table
aliasstring (optional)

The table syntax is the same as the table portion of the column expression syntax

table           = system-table-name | database-table
database-table  = database-path ['@' database-table-name]

May also be provided directly as a JSON string (without the alias property).

System Table Source

Deprecated

A source from a system table.

PropertyValue
type"table_system" or "ts"
tablestring table name
aliasstring (optional)

Database Table Source

A source from a database table.

PropertyValue
type"table_database" or "td"
databasedatabase specifier
tablestring table name
aliasstring (optional)

Join Source

A source derived from a SQL join of two sources.

PropertyValue
type"join"
op"join", "left", "left_outer", "inner", or "cross"
s1left join source
s2right join source

Select Source

Source from the result of a select statement.

PropertyValue
type"select"
selectselect

Order Term

Specifies an expression and optional order.

PropertyValue
eexpression
order"asc" or "desc" (optional, default "asc"