A newer version of this documentation is available.

View Latest

SELECT Syntax

select::= select-term [ set-op [ ALL ] ] [ order-by-clause | limit-clause | offset-clause ]

select
Figure 1. Railroad Diagram: select

select-term::= subselect | "(" select ")"

select term
Figure 2. Railroad Diagram: select-term

subselect::= select-from | from-select

subselect
Figure 3. Railroad Diagram: subselect

select-from::= select-clause [ from-clause | let-clause | where-clause | group-by-clause ]

select from
Figure 4. Railroad Diagram: select-from

from-select::= from-clause [ let-clause ] [ where-clause ] [ group-by-clause ] select-clause

from select
Figure 5. Railroad Diagram: from-select

SELECT Clause

select-clause::= SELECT [ ALL | DISTINCT ] ( result-expr [ , result-expr ]* | ( RAW | ELEMENT | VALUE ) expr [ [AS] alias ] )

select clause
Figure 6. Railroad Diagram: select-clause

FROM Clause

from-clause::= FROM from-term

from clause
Figure 7. Railroad Diagram: from-clause

from-term::= from-keyspace [ [ AS ] alias ] [ use-clause ] | "(" select ")" [ AS ] alias | expr [ [ AS ] alias] | from-term ( join-clause | nest-clause | unnest-clause )

from term
Figure 8. Railroad Diagram: from-term

from-keyspace::= [ namespace : ] keyspace

from keyspace
Figure 9. Railroad Diagram: from-keyspace

JOIN Clause

join-clause::= [ join-type ] JOIN from-keyspace [ [ AS ] alias ] join-predicate

join clause
Figure 10. Railroad Diagram: join-clause

join-type::= INNER | LEFT [ OUTER ]

join type
Figure 11. Railroad Diagram: join-type

join-predicate::= lookup-join-predicate | index-join-predicate

join predicate
Figure 12. Railroad Diagram: join-predicate

lookup-join-predicate::= ON [ PRIMARY ] KEYS expr

lookup join predicate
Figure 13. Railroad Diagram: lookup-join-predicate

index-join-predicate::= ON [ PRIMARY ] KEY expr FOR alias

index join predicate
Figure 14. Railroad Diagram: index-join-predicate

NEST Clause

nest-clause::= [ join-type ] NEST from-keyspace [ [ AS ] alias ] join-predicate

nest clause
Figure 15. Railroad Diagram: nest-clause

UNNEST Clause

unnest-clause::= [ join-type ] ( UNNEST | FLATTEN ) expr [ [ AS ] alias ]

unnest clause
Figure 16. Railroad Diagram: unnest-clause

USE Clause

use-clause::= use-keys-clause | use-index-clause

use clause
Figure 17. Railroad Diagram: use-clause

use-keys-clause::= USE [ PRIMARY ] KEYS expr

use keys clause
Figure 18. Railroad Diagram: use-keys-clause

use-index-clause::= USE INDEX "(" index-ref [ "," index-ref ]* ")"

use index clause
Figure 19. Railroad Diagram: use-index-clause

index-ref::= index-name [ index-using ]

index ref
Figure 20. Railroad Diagram: index-ref

index-name::= identifier

index name
Figure 21. Railroad Diagram: index-name

index-using::= USING ( VIEW | GSI )

index using
Figure 22. Railroad Diagram: index-using

LET Clause

let-clause::= LET alias "=" expr [ "," alias = expr ]*

let clause
Figure 23. Railroad Diagram: let-clause

WHERE Clause

where-clause::= WHERE cond

where clause
Figure 24. Railroad Diagram: where-clause

cond::= expr

cond
Figure 25. Railroad Diagram: cond

GROUP BY Clause

group-by-clause::= GROUP BY expr [ "," expr ]* [ letting-clause ] [ having-clause ] | letting-clause

group by clause
Figure 26. Railroad Diagram: group-by-clause

letting-clause::= LETTING alias "=" expr [ "," alias = expr ]*

letting clause
Figure 27. Railroad Diagram: letting-clause

having-clause::= HAVING cond

having clause
Figure 28. Railroad Diagram: having-clause

set-op::= UNION | INTERSECT | EXCEPT

set op
Figure 29. Railroad Diagram: set-op

ORDER BY Clause

order-by-clause::= ORDER BY ordering-term [ "," ordering-term ]*

order by clause
Figure 30. Railroad Diagram: order-by-clause

ordering-term::= expr [ ASC | DESC ]

ordering term
Figure 31. Railroad Diagram: ordering-term

LIMIT Clause

limit-clause::= LIMIT expr

limit clause
Figure 32. Railroad Diagram: limit-clause

offset-clause::= OFFSET expr

offset clause
Figure 33. Railroad Diagram: offset-clause