If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Which is quicker

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-15-03, 10:43
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
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.
Reply With Quote
  #2 (permalink)  
Old 10-16-03, 21:42
christodd christodd is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On