parenthesis and order of operations question?!?!?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can somebody explain (or point in the right direction) to me why a second set
of parenthesis is needed??

Does it have to do with order of operations? I know I have to use them when
I alias a table (in Access) or the statement won't work.

WHERE (((Publishers.PublisherName)="jimbob publishing"))

I have a number of SQL books but they never explain as to why they are
needed or I should say how they are used correctly in statements ,at least
from what I have read.
 
awrex said:
Can somebody explain (or point in the right direction) to me why a second set
of parenthesis is needed??

Does it have to do with order of operations? I know I have to use them when
I alias a table (in Access) or the statement won't work.

WHERE (((Publishers.PublisherName)="jimbob publishing"))

I have a number of SQL books but they never explain as to why they are
needed or I should say how they are used correctly in statements ,at least
from what I have read.

The extra parentheses are not needed. Access is utterly
parenthesis-happy. As your example stands there is no difference between

(((Publishers.PublisherName)="jimbob publishing"))

and

Publishers.PublisherName="jimbob publishing"

Having said that, parentheses are quite necessary when establishing
order of operations other than the default is required. E.g.,

WHERE a OR b AND c

is not the same as

WHERE (a OR b) AND c ,

as well as in certain constructs like subqueries, as you mentioned.

Parentheses are also quite useful to make grouping clear, although
referring back to the original example, I find that Access overdoes it.
Moreover, if you attempt to use parentheses to set off logical blocks to
make them understandable, like

WHERE a =
(
( SELECT ... )
OR b
)

Access will invariably foil you by reducing the whitespace and line
breaks to something almost, but not entirely unlike readable code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top