What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » SQL Help (Joins)

SQL Help (Joins)
Author: Message:
Adeptus
Senior Member
****


Posts: 732
Reputation: 40
Joined: Oct 2005
RE: SQL Help (Joins)
Your understanding is essentially correct.  I will give you my definitions anyway, though.

quote:
Originally posted by lordy
Inner Join - Returns rows from both tables where the condition(s) are matched.
An INNER JOIN returns a single joined row from the individual rows of joined tables, where the join conditions are met.  Nothing is returned for rows in either table that do not meet the join conditions.

quote:
Originally posted by lordy
Left Join - Returns all rows from the first table, and those rows from the second table where there is a match with the condition(s).
Right Join - Returns all rows from the second table and those rows from the first table where there is a match with the condition(s).
The full names for these are LEFT OUTER JOIN and RIGHT OUTER JOIN.  An OUTER join returns all rows from one of the tables (LEFT or RIGHT relative to JOIN keyword and, of course, subject to any applicable WHERE clause).  Where the other table has no rows that meet the join conditions (and WHERE clause, if any), the row from the designated (LEFT or RIGHT) table will still be returned in your results, but the values of joined columns from the other table will be NULL.

Finally: 

1) There is also a CROSS JOIN, which takes no conditions and returns all possible combinations of joined rows in both tables, subject to any applicable WHERE clause.

2) You don't necessarily have to SELECT any columns to return from a table involved in a join.  You can still use INNER JOIN against another table to limit the returned results to those that match your join condition against said table.  This trick often enables one to avoid using a subquery (although there is nothing wrong with using subqueries on databases that support them).

3) Using table aliases, you can join the same table to itself as many times as needed.  This comes in handy when you have rows with a parent-child relationship contained in the same table, as well as for finding duplicates.

This post was edited on 06-30-2006 at 02:25 AM by Adeptus.
06-30-2006 02:10 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
SQL Help (Joins) - by lordy on 06-30-2006 at 12:28 AM
RE: SQL Help - by Jhrono on 06-30-2006 at 12:38 AM
RE: SQL Help - by lordy on 06-30-2006 at 01:24 AM
RE: SQL Help (Joins) - by Adeptus on 06-30-2006 at 02:10 AM
RE: SQL Help (Joins) - by lordy on 06-30-2006 at 02:36 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On