Link to home
Start Free TrialLog in
Avatar of Mr_Fulano
Mr_FulanoFlag for United States of America

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mr_Fulano

ASKER

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
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
Thanks!