sql - Is too many Left Joins a code smell? -
If you have an example> 5 questions are included in a query then it is a code odor. ..
- Is there something wrong with your design?
- Are you doing a lot in a question?
- Are you databases quite common?
- - How to get rid of
instead ofreplacedoes not exist < / Code>
This is a perfectly legitimate solution for some designs.
Say that you have a hierarchy Customer - order - basket - items - One-to-many relationships like value order with a , can not be a customer order basket , etc.
In this case, you issue something like this:
SELECT * to customer C LEFT OUTER JOIN OO O. COMPUTER ID = CID left outer basket by on B.OrderID = c.ID ... Note that this may be disabled in some cases, and EXISTS or not existing < / Code> (if you want to know only that the related records are present or not present in other tables).
See this article in my blog for display details:
Comments
Post a Comment