8.5.3 SQL EBNF

Terminals are in bold or in single quotes.

query ::= select [from] [where] [orderby]


select ::= SELECT ('*' | proplist )

from ::= FROM ntlist

where ::= WHERE whereexp

orderby ::= ORDER BY propname [DESC|ASC]

{',' propname [DESC|ASC]}


proplist ::= propname {',' propname}


ntlist ::= ntname {',' ntname}


whereexp ::= propname op value |

propname IS NULL |

propname IS NOT NULL |
value IN propname |
like |

contains |
whereexp AND whereexp |
whereexp OR whereexp |
NOT whereexp |
'(' whereexp ')'



op ::= '='|'>'|'<'|'>='|'<='|'<>'


propname ::= joinpropname | simplepropname


joinpropname ::= quotedjoinpropname |
unquotedjoinpropname


quotedjoinpropname ::= ''' unquotedjoinpropname '''


unquotedjoinpropname ::= ntname '.jcr:path'


simplepropname ::= quotedpropname | unquotedpropname


quotedpropname ::= ''' unquotedpropname '''


unquotedpropname ::= /* A property name, possible a pseudo-property: jcr:score or jcr:path */


ntname ::= quotedntname | unquotedntname


quotedntname ::= ''' unquotedntname '''


unquotedntname ::= /* A node type name */


value ::= ''' literalvalue ''' | literalvalue


literalvalue ::= /* A property value (in standard string
form) */


like ::= propname LIKE likepattern [ escape ]

likepattern ::= ''' likechar { likepattern } '''


likechar ::= char | '%' | '_'


escape ::= ESCAPE ''' likechar '''


char ::= /* Any character valid within the
string representation of a value
except for the characters % and _
themselves. These must be escaped */


contains ::= CONTAINS(scope ',' searchexp ')'

scope ::= unquotedpropname | '.'

searchexp ::= ''' exp '''


exp ::= [-]term {whitespace [OR] whitespace [-]term}


term ::= word | '"' word {whitespace word} '"'


word ::= /* A string containing no whitespace */


whitespace ::= /* A string of only whitespace*/