Subject | Circular join question |
---|---|
Author | Rick DeBay |
Post date | 2005-01-19T18:58:20Z |
I have a circular relationship:
Top_Entity1 <-- Entity_Group <-- Entity1_Entity2_Link
^ |
| |
| V
Child <-- Child_Entity2_Link <-- Top_Entity2
To get the information I need, there are at least five joins.
I don't know if I should add a sixth join to close the circle, or a
where clause to do it.
For example, given that all other parts of the SQL consist of joins,
should I finish with
JOIN Child_Entity2_Link a ON a.Top_Entity2 = Top_Entity2.ID
or
WHERE Child_Entity2_Link.Top_Entity2 = Top_Entity2.ID
I ask because Child_Entity2_Link is what started the join statements,
with
FROM Child_Entity2_Link JOIN Top_Entity1 ON ...
and I don't know if it is correct to have the join closed like that, or
a burden on the engine.
Rick DeBay
Senior Software Developer
RxStrategies.net
Top_Entity1 <-- Entity_Group <-- Entity1_Entity2_Link
^ |
| |
| V
Child <-- Child_Entity2_Link <-- Top_Entity2
To get the information I need, there are at least five joins.
I don't know if I should add a sixth join to close the circle, or a
where clause to do it.
For example, given that all other parts of the SQL consist of joins,
should I finish with
JOIN Child_Entity2_Link a ON a.Top_Entity2 = Top_Entity2.ID
or
WHERE Child_Entity2_Link.Top_Entity2 = Top_Entity2.ID
I ask because Child_Entity2_Link is what started the join statements,
with
FROM Child_Entity2_Link JOIN Top_Entity1 ON ...
and I don't know if it is correct to have the join closed like that, or
a burden on the engine.
Rick DeBay
Senior Software Developer
RxStrategies.net