John W. Colby
jwcolby at colbyconsulting.com
Wed May 4 10:42:29 CDT 2005
Inner and outer joins simply perform different functions in the overall scheme of things so you can't really say "avoid them if possible". An inner join says "only give me records where there is data in both tables". This is used to enforce rules (for example) - if there is no invoice for this client, don't return a record in the invoice report - stuff like that. Outer joins are precisely to allow breaking such rules, allow me to see all clients, WITH ANY INVOICES... But also show clients where there is no invoice. Which you use depends entirely on your purpose with the query. You may be able to use an outer join to only display records where there is data in both tables, but that would require jumping through many hoops I'm guessing. And AFAIK you simply cannot use an inner join to display data where there is no data in the related table. They are just different animals used for different things. In my mind your question doesn't make sense. John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy Pang Sent: Wednesday, May 04, 2005 2:48 AM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] outer joins? Hello: Can I ask for the group's opinion about something? Is there any performance differences between an INNER JOIN and an OUTER JOIN query? I know the two joins may or may not produce the same resultset (depending on data) but I am curious if anyone has come across any difference in terms of performance, generally speaking of course. Should OUTER JOINs be avoided in general unless absolutely necessary? Thanks Billy _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com