Inner joins return only those rows from both sql database tables having matching records in both the tables whereas left outer join returns all the rows from the left table and related matching records from the other one.
SQL Left Outer Join Example:
USE PUBS
SELECT A.AU_FNAME, A.AU_LNAME, P.PUB_NAME FROM AUTHORS A LEFT OUTER JOIN PUBLISHERS P ON A.CITY = P.CITY ORDER BY A.AU_LNAME, A.AU_FNAME
Result:
au_fname
au_lname
pub_name
Abraham
Bennet
Algodata Infosystems
Reginald
Blotchet-Halls
NULL
Cheryl
Carson
Michel
DeFrance
Innes
del Castillo
Ann
Dull
Marjorie
Green
Morningstar
Greene
Burt
Gringlesby
Sheryl
Hunter
Livia
Karsen
Charlene
Locksley
Stearns
MacFeather
Heather
McBadden
Michael
O'Leary
Sylvia
Panteley
Albert
Ringer
Anne
Meander
Smith
Dean
Straight
Dirk
Stringer
Johnson
White
Akiko
Yokomoto
This left outer join query retrieves the author names and publisher name having same cities. Here all rows retrieved from the left table i.e. authors and publisher name having the similar city other columns of pub_name column are null due to no match found in the right table.
Learn SQL Inner Joins:
SQL Inner Equi Join Examples
SQL Inner Natural Join Examples
SQL Inner Join Examples
Be the first to rate this post
Tags: sql, sql outer joins, sql joins, sql left outer join, sql join examples, sql inner join
10/14/2008 1:07:21 PM