Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: LEFT & RIGHT JOIN


Message #1 by "Mark Irvine" <mark@m...> on Fri, 2 Nov 2001 14:36:38 -0000
Blair,

Many thanks for your explanation - has made things very clear.

Mark
Blair Potts <pottssoftware@m...> wrote in message
news:117283@s..._language...
>
> Mark,
>
> Forgive me if this explanation is too verbose or just not clear.
>
> Imagine two tables:
>      Table 1                        Table 2
> a1     b1     c1               a2      b2      c2
> 1      A      W                1       X       Y
> 6      V      R                4       X       B
>
> The statement "SELECT 1.b1, 2.c2 FROM TABLE 1 AS 1 INNER JOIN TABLE 2 AS 2
> ON 1.a1=2.a2"  would give you:
> b1     c2
> A      Y
>
> An INNER JOIN includes only the results from the joined tables that are
> true for the ON condition.  Thus,  INNER JOINS don't have RIGHT or LEFT
> Keywords.
>
> An OUTER JOIN will include results that do AND don't hold true for the ON
> condition. The RIGHT and LEFT Keywords limit the results to either the
> table name appearing to the right of the word "JOIN" or to its left:
> "SELECT 1.b1, 2.c2 FROM TABLE 1 AS 1 LEFT OUTER JOIN TABLE 2 AS 2 ON
> 1.a1=2.a2"
> Gives
> b1     c2
> A      Y
> V      NULL
>
> "SELECT 1.b1, 2.c2 FROM TABLE 1 AS 1 RIGHT OUTER JOIN TABLE 2 AS 2 ON
> 1.a1=2.a2"
> Gives
> b1     c2
> A      Y
> NULL   B
>
>
> > Hi,
> >
> > I was wondering if some could explain to me the basics of LEFT JOIN and
> > RIGHT JOIN.  I have seen them used before, but have never understood
> them.
> >
> > Many thanx,
> >
> > Mark
> >
> >
>
> > Hi,
> >
> > I was wondering if some could explain to me the basics of LEFT JOIN and
> > RIGHT JOIN.  I have seen them used before, but have never understood
> them.
> >
> > Many thanx,
> >
> > Mark
> >
> >
>
>



  Return to Index