Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 485
  • Last Modified:

Parenthetical Hierarchy in the SELECT Statement

Hi, I'm using Access 2003. I'm not an SQL Guru, but rather I'm trying to learn as much as I can so that I can write good sound SQL statements. My question is regarding the parenthesis in the SELECT statement and how they are processed.

In a mathematical computation, there is a hierarchy as to which part of the equation is resolved first and which follows second and so on. -- Does that same hierarchy apply to the parenthesis; or better put, the statements within those parenthesis inside an SQL statement.

The parenthesis I'm referring to are like the ones below

SELECT *
FROM ((Table1
LEFT JOIN Table2 ON ...)
LEFT JOIN Table3 ON ...)
LEFT JOIN Table4 ON...

Does Table1 get evaluated first or which one if any gets evaluated first and why?

Thanks,
Fulano
0
Mr_Fulano
Asked:
Mr_Fulano
  • 2
  • 2
1 Solution
 
Patrick MatthewsCommented:
Hello Mr_Fulano,

As with normal arithmetic, the innermost parenthetical expression gets evaluated first, and you move outward
from there.

Regards,

Patrick
0
 
Mr_FulanoAuthor Commented:
Hi Patrick, so based on your answer, the way I group the expressions makes a big difference in my results.

Are there cases where some parenthesise MUST be grouped in a certain manner?

Thanks,
Fulano
0
 
Patrick MatthewsCommented:
Mr_Fulano,

Not sure how to answer your question, except to say that you have to arrange your parentheses such that
all operations are performed in the order in which you want them to occur.

Regards,

Patrick
0
 
Mr_FulanoAuthor Commented:
Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now