Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JOINs with parenthesis 1

Status
Not open for further replies.

Romanichine

Programmer
Apr 9, 2002
30
CA
Can someone tell me where the parenthesis, to separate the joins, should be in the following query?

==============
SELECT *
FROM valid_sales_ids s RIGHT OUTER JOIN direct_services
ON s.sales_id = direct_services.sales_id RIGHT OUTER JOIN client INNER JOIN currencies cur
ON client.currency_id = cur.currency_id INNER JOIN languages l
ON client.language_code = l.language_code INNER JOIN companies
ON client.company_id = companies.company_id LEFT OUTER JOIN valid_terminations v
ON client.termination_code = v.termination_code
ON direct_services.client_id = client.client_id
==============

Thank you,
--
Roman.
 
These things are always tricky, and this one is particularly thorny. I would guess this:

SELECT *
FROM valid_sales_ids s
RIGHT OUTER JOIN direct_services
ON s.sales_id = direct_services.sales_id
RIGHT OUTER JOIN
(
client
INNER JOIN currencies cur
ON client.currency_id = cur.currency_id
INNER JOIN languages l
ON client.language_code = l.language_code
INNER JOIN companies
ON client.company_id = companies.company_id
LEFT OUTER JOIN valid_terminations v
ON client.termination_code = v.termination_code
)
ON direct_services.client_id = client.client_id
---------------------
Hope it works!
bperry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top