Re: SQL Standard on parentheses
Date: Mon, 25 Feb 2002 15:10:45 -0800
Message-ID: <3c7ac475_at_rpc1284.daytonoh.ncr.com>
"Jeff Zucker" <jeff_at_vpservices.com> wrote in message
news:3C7AA6DE.E24EB680_at_vpservices.com...
> I can't find anything in any of the standards which says whether this is
> a valid statement:
>
> SELECT *
> FROM a
> WHERE (b < c)
> AND (d > e)
>
> The parentheses obviously don't indicate anything about precedence. Is
> a standards complying parser obligated to accept these purely
> "decorative" additions or even uglier things like:
>
> ... WHERE ( (b<c) AND (d>e) ) ORDER BY f
>
The standard seems perfectly clear on this. Here is the relevant SQL-99
grammar
(the SQL-92 grammar is somewhat different, but it still allows all of the
above
cases):
<search condition> ::= <boolean value expression>
<boolean value expression> ::=
<boolean term>
| <boolean value expression> OR <boolean term>
<boolean term> ::=
<boolean factor>
| <boolean term> AND <boolean factor>
<boolean factor> ::=
[ NOT ] <boolean test>
<boolean test> ::=
<boolean primary> [ IS [ NOT ] <truth value> ]
<truth value> ::=
TRUE
| FALSE
| UNKNOWN
<boolean primary> ::=
<predicate> | <parenthesized boolean value expression> | <nonparenthesized value expression primary> <parenthesized boolean value expression> ::= <left paren> <boolean value expression> <right paren>Received on Tue Feb 26 2002 - 00:10:45 CET