Syntax

The following formal grammar is extracted from the grammar for the Where clauses of MS SQL Server. Please note that not all databases support the same set of operators. Furthermore the formats of literals are different in each database. Use parameters to avoid problems with literals.

 

< search_condition > ::=

    {    [ NOT ] < predicate > | ( < search_condition > ) }

        [ { AND | OR } [ NOT ] { < predicate > | ( < search_condition > ) } ]

    }    [ ,...n ]

 

< predicate > ::=

    {    expression { = | < > | ! = | > | > = | ! > | < | < = | ! < } expression

        | string_expression [ NOT ] LIKE string_expression

            [ ESCAPE 'escape_character' ]

        | expression [ NOT ] BETWEEN expression AND expression

        | expression IS [ NOT ] NULL

    }

 

<expression> ::=

{  persistent_field_name

    | parameter   

    | constant

    | ( expression )

    | { unary_operator } expression

    | expression { binary_operator } expression

}

unary_operator:

+ (Positive), - (Negative), ~ (Bitwise NOT)

parameter:

{n} (n = 0 .. number of parameters - 1)

 

binary_operator:

* (Multiply), / (Division), % (Modulo)

+ (Add), (+ Concatenate), - (Subtract), & (Bitwise AND)

^ (Bitwise Exclusive OR), | (Bitwise OR)

 

comparison_operator

=,  >,  <,  >=,  <=,  <>,  !=,  !>,  !<