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?
  • 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 customer , can not be a 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:

    • - How to get rid of instead of replace does not exist < / Code>

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -