About inner join disadvantage

  • Unknown's avatar

    Hi,
    I have one question about inner join query in sql 2008. Is there any situation where NOT to use inner joins.
    I have one scenario please tell me that here inner join is fuitful or not.

    I have 2 tables
    Talbe1 Columns: T1Id, Code and Name1, (Here Code is unique column)
    Table2 Columns: T2Id, T1id(reference from Table 1), Name2, Type

    Now there can be millons of records in both table. Now user pass the Code and I have to search the Name2 3 times in same procedure for diff condition.
    I can do it with 2 scenario. Scenarion1:
    i can store T1Id in temp variable
    Declare @Id Int
    Select @Id=Top1 T1Id from Table1 Where Code=’ABC’,
    Step 2: I will write all my queries
    Select Name2 From Table2 Where T1id=@Id and Type=’A’
    Select Name2 From Table2 Where T1id=@Id and Type=’B’
    Select Name2 From Table2 Where T1id=@Id and Type=’C’

    Scenario 2:
    Select Name2 From Table2 Inner join Table1 on Table1.T1ITable2.T1Id
    Where Table2.Type=’A’ and Table1.Code=’ABC’
    Select Name2 From Table2 Inner join Table1 on Table1.T1ITable2.T1Id
    Where Table2.Type=’B’ and Table1.Code=’ABC’
    Select Name2 From Table2 Inner join Table1 on Table1.T1ITable2.T1Id
    Where Table2.Type=’C’ and Table1.Code=’ABC’

    Please tell me which one is good to use. Both tables can have more than millions records in future.

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    Are you asking in reference to this blog: http://rajeshbailwal.wordpress.com/ ?

  • Unknown's avatar

    You cannot access or work with the SQL tables here at wordpress.com which leads me to believe you are self-hosted and need to be inquiring at wordpress.ORG forums, or more appropriately at some MySQL forum of some sort rather than at wordpress since this does not appear to be directly related to wordpress.

  • Unknown's avatar

    where to post such question. I am not getting the proper path.

  • Unknown's avatar

    You need to search on the internet for mysql forums since this really doesn’t seem to be a wordpress issue. Search on Google for something like

    mysql forum

  • The topic ‘About inner join disadvantage’ is closed to new replies.