[thelist] sql statement

Donnie Blaker filterhead80 at hotmail.com
Wed Mar 30 08:18:36 CST 2005


So let me ask a another question, if no one minds.
If I have a query that pulls some information a straight select statement 
that pulls name occupation salary and then has an address id, can I using an 
INNER JOIN or an OUTER JOIN to pull that information in the same statement.

so that one query would get name occupation salary address1 address2 city 
state zip phone? or would that require two queries?

>From: "Ken Schaefer" <Ken at adOpenStatic.com>
>Reply-To: "thelist at lists.evolt.org" <thelist at lists.evolt.org>
>To: <thelist at lists.evolt.org>
>Subject: RE: [thelist] sql statement
>Date: Wed, 30 Mar 2005 08:56:42 +1000
>
>INNER JOIN requires a match on both sides.
>
>OUTER JOIN does not require a match, and where there is no match, a NULL 
>will
>be substituted. Depending on whether you use a LEFT OUTER JOIN, RIGHT 
>OURTER
>JOIN, or FULL OUTER JOIN, you will get NULLs on the right, left, or both
>sides.
>
>-- always require a match in table1 with table2
>INNER JOIN
>	Table2
>ON
>	Table1.ID = Table2.ID
>
>-- if no match in table2, then select the fields from
>-- table1, and put in NULLs for the table2 fields
>LEFT OUTER JOIN
>	Table2
>ON
>	Table1.ID = Table2.ID
>
>-- if no match in table1, then select the fields from
>-- table2, and put in NULLs for the table1 fields
>RIGHT OUTER JOIN
>	Table2
>ON
>	Table1.ID = Table2.ID
>
>-- select all records, and if no match
>-- substitute a NULL on either the left or right
>FULL OUTER JOIN
>	Table2
>ON
>	Table1.ID = Table2.ID
>
>Cheers
>Ken
>
>--
>www.adOpenStatic.com/cs/blogs/ken/
>
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>: From: thelist-bounces at lists.evolt.org [mailto:thelist-
>: bounces at lists.evolt.org] On Behalf Of Donnie Blaker
>: Subject: Re: [thelist] sql statement
>:
>: if you dont mind me asking, whats the difference between an inner and an
>: outer
>:
>: >From: Ed McCarroll <Ed at ComSimplicity.com>
>: >Reply-To: "thelist at lists.evolt.org" <thelist at lists.evolt.org>
>: >To: "thelist at lists.evolt.org" <thelist at lists.evolt.org>
>: >Subject: Re: [thelist] sql statement
>: >Date: Tue, 29 Mar 2005 13:52:24 -0800
>: >
>: >To list all size names for product 213:
>: >
>: >   SELECT size.name
>: >   FROM size S
>: >   INNER JOIN prod_size PS
>: >     ON S.sid = PS.sid
>: >   WHERE PS.prodid = 213
>: >
>: >or equivalent...
>: >
>: >--
>: >Ed McCarroll                                  (310) 838-4330
>: >Ed at ComSimplicity.com            http://www.ComSimplicity.com
>: >
>: >
>: >Quoting Donnie Blaker <filterhead80 at hotmail.com>:
>: >
>: > > I have two tables.  sizes and prod_size.
>: > >
>: > > size has sid, name, abrv
>: > > prod_size has sid, prodid
>: > >
>: > > when I do this look up I would like in one query get the all the
>: > > sizes for
>: > > that product.  normally I would do two queries but I dont think
>: > > that is the
>: > > correct way.
>: > >
>: > > does someone know what I would use?  like left join or join or
>: > > something
>: > > like that
>: > >
>: > > thanks
>--
>
>* * Please support the community that supports you.  * *
>http://evolt.org/help_support_evolt/
>
>For unsubscribe and other options, including the Tip Harvester
>and archives of thelist go to: http://lists.evolt.org
>Workers of the Web, evolt !

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/



More information about the thelist mailing list