Jim, you typically use a JOIN for what you describe but there are ample
circumstances to use a UNION (for example you very often save a lot of
processing time if your query contains an IN (or a NOT IN) clause by using
UNION instead of JOIN). I think a good rule of thumb is that you should use
JOIN (and its several variants) until such time as you know when to use
UNION. That sounds like a catch-22 but really by the time you get to the
point where it would make a difference, you will often know enough to know
the distinction.

just as a quick example, suppose you had a query like
SELECT Customers.CustomerName FROM Customers WHERE CustomerName  IN
('Jones', 'Smith')

for a everyday kinda app this might be not a problem. However if there were
many thousands of records in the table and the IN clause were much longer,
you could really bog the db server down with such a beast. Much better to
execute each as a separate query (e.g.,WHERE CustomerName = 'Jones') and
then UNION them all.   The problem is even more exacerbated were this, say,
a NOT IN, since then the returned record-set you are looking for may well be
HUGE. A good  trick is to try to apply the condition (or join) first which
reduces the set the most (from which subsequent conditions will be applied)



> -----Original Message-----
> From: Ray, James A [mailto:[EMAIL PROTECTED]]
> Sent: 24 August 2000 16:33
> Subject: Join vs Union Perference
>
> Which is a better perference, using a Join or Union?
> I need to link together several tables so I can build an excel spreadsheet



------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to