When to use Subqueries versus joins?
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: When to use Subqueries versus joins?

  1. #1
    Join Date
    Nov 2001
    Location
    Singapore
    Posts
    182

    When to use Subqueries versus joins?

    When to use Subqueries versus joins?


    On what scenario it is better to use JOINS over Sub queries?
    J Gangadhar

  2. #2
    Join Date
    Aug 2002
    Location
    Atlanta
    Posts
    1,187
    I always use joins on Thursday's and avoid sub quereies in leap years
    I'm stmontgo and I approve of this message

  3. #3
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092

    Re: When to use Subqueries versus joins?

    Originally posted by ganga
    On what scenario it is better to use JOINS over Sub queries?
    Always, except when it doesn't matter.
    Jeff Hunter
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

  4. #4
    Join Date
    Oct 2002
    Posts
    182
    you need to benchmark all varieties to determine if a join scales better than a subquery (or vice-versa).

    An 'IN' clause can work great if you are working against NOT NULL columns within the subquery (like a PK). Sometime an EXISTS clause is better if you know you only need to check for an existence of at least one row.

    Joins are more efficient sometimes if you need columns from the joined table.
    - Cookies

  5. #5
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    "No join "/"No Subquery" is still better.

    Tamil

  6. #6
    Join Date
    Oct 2002
    Posts
    182
    Originally posted by tamilselvan
    "No join "/"No Subquery" is still better.

    Tamil
    I didn't understand your statement there.
    - Cookies

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width