Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778

    Unanswered: Which is quicker

    Hi,

    Generally speaking which is the quicker option

    select x
    from table a, table b
    where a.x = b.x
    or
    select x
    from table a
    where a.x IN
    (select b.x
    from table b)

    Also if there are 2 join conditions such as a.x = b.x AND a.c = b.c

    Thanx.

  2. #2
    Join Date
    Oct 2003
    Posts
    16

    The first, but better is

    The first way is quicker, since it doesn't build a temporary table in memory for the set.

    BUT - most database engines will perform even faster if you use the JOIN syntax.

    Select a.x
    FROM tablea a
    JOIN tableb b
    WHERE a.x=b.x

    And make sure that a.x and b.x are primary keys !!!

    -Chris
    visit my BiteSize SQL Tutorial

Posting Permissions

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