sql confused

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bhakhra
    New Member
    • Jan 2008
    • 6

    sql confused

    Hi all, I am not too savvy when it comes to joining tables and running queries with SQL accessing mutiple tables..is there a rule of thumb when to join tables and when not to.. even when a user is working with more than one table and comparing column values?
    thanks for your help in advance
    Last edited by bhakhra; Apr 3 '08, 08:34 PM. Reason: TYPO
  • docdiesel
    Recognized Expert Contributor
    • Aug 2007
    • 297

    #2
    Hi,

    I don't think there's a rule of thumb when to join tables. But when joining tables make sure that the columns you use in the conditions are primary keys or are otherwise indexed.

    Regards,

    Bernd

    Comment

    • sakumar9
      Recognized Expert New Member
      • Jan 2008
      • 127

      #3
      There is no hard and fast rule to say when to join tables or not. Tables are joined if its needed, like if you want to get the data from two tables.

      Some rules can be suggested on how to join the tables to get best performance. A general rule of thumb says: The table with maximum cardinality should be kept in left most position(first position). This will give you performance benefits.

      If you think that the query is taking long to execute, then check the access plan and try to find the loophole.


      Regards
      -- Sanjay

      Comment

      Working...