Link to home
Start Free TrialLog in
Avatar of hanglam1
hanglam1

asked on

Nested Inner Join Question ??

This is basically a question about how an inner joins works .

I have this query :

Select a1.Name, b2.Name, c3.Name, d4.Name
from a1
inner join b2
on a1.NameID = b2.NameID
inner join c3
on a1.NameID = c3.NameID
inner join d4
on a1.NameID = d4.NameID

and

Select a1.Name, b2.Name, c3.Name, d4.Name
from a1
inner join b2
on a1.NameID = b2.NameID
inner join c3
on b2.NameID = c3.NameID
inner join d4
on c3.NameID = d4.NameID


The differences are on the "ON Clause" . Would there be difference on results between these two queris ?

How does a inner nested query work ?

I always thought, the query will first resolve the first inner query and use that result to do the second inner query and so on.

Thanks,
Hang

Avatar of ptjcb
ptjcb
Flag of United States of America image

What is the database?
Avatar of hanglam1
hanglam1

ASKER

ptjcb ,

The database is Microsoft SQL Server 2000
SOLUTION
Avatar of izblank
izblank

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
SOLUTION
Avatar of Ralf Klatt
Ralf Klatt
Flag of Germany 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
SOLUTION
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
ASKER CERTIFIED SOLUTION
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
Hi,

@BigSchmuh ... thanks for the comment in my direction ... not to excuse myself for my statement ... and surely not for seeming offending! ... but, I keep with my opinion that an Inner Join used in a query is more efficient than an outer join ... -> depending on the target of the query ... of course!


Best regards,
Raisor
I just want it to confirm with the experts here  that both inner joins return the same values. I tested the queries in MSSQL Query Analyze before and it did return the same values.

Thanks all,
Hang