POV-Ray : Newsgroups : povray.off-topic : Question for SQLers out there : Re: Question for SQLers out there Server Time
10 Oct 2024 21:17:19 EDT (-0400)
  Re: Question for SQLers out there  
From: Dan Byers
Date: 12 Feb 2008 09:40:00
Message: <web.47b1af39e388923da8d0b25a0@news.povray.org>
Tom Austin <taustin> wrote:
> OK, I've heard a lot about inner joins and outer joins but don't really
> know them or how to use them.
>
> I've actually been using SQL for 10 years now, but never managed to
> completely figure this out.
>
>
> Lets say I have (2) tables - (2) column each
>
> Person    Limbs
> Index Name   PersonIndex Type
>
>
>
> Now, I would normally write a SQL statement like this:
>
> select L.Type from Person P, Limbs L where L.PersonIndex = P.Index and
> P.Name = 'Bones'
>
> This *works*, but somehow I feel that this is where the JOIN should come in.
>
>
> Should a JOIN be used here?
> Does it matter?
>
>
> Thanky..... Tom

Inner Join equivalent:

SELECT  L.TYPE
FROM    PERSON P INNER JOIN LIMBS L ON
             P.INDEX = L.PERSONINDEX
WHERE   P.NAME = 'Bones'

Your example would be fine, although supposedly M$ frowns on that and is trying
to steer people away from it.

An Inner Join will only pull where there's a match in both tables.

The left outer join pulls all the records on the left side of the join and any
matching records from the right side table, or NULL if no matches are made.  A
right outer join works in the opposite direction (but I've never used it, so I
don't know for sure).

This is an outer join example:

SELECT  P.NAME, L.TYPE
FROM    PERSON P LEFT OUTER JOIN LIMBS L ON
             P.INDEX = L.PERSONINDEX

Here, I want to pull all the P.NAMES from PERSON, regardless if they have limbs
or not.


Hopethishelps...

--
Dan
GoofyGraffix.com


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.