Excellent explanation. Thank you!

-Bill

> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of Simon Slavin
> Sent: Monday, July 28, 2014 6:20 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] SQL Join question
>
>
> On 28 Jul 2014, at 9:10pm, Drago, William @ MWG - NARDAEAST
> <william.dr...@l-3com.com> wrote:
>
> > Can someone tell me what the purpose of line 2 is in the following
> example? It seems redundant to me since what is wanted from the
> Customers table is specified on line 1.
> >
> >
> > 1: SELECT Customers.CustomerName, Orders.OrderID
> > 2: FROM Customers
> > 3: INNER JOIN Orders
> > 4: ON Customers.CustomerID=Orders.CustomerID
> > 5: ORDER BY Customers.CustomerName;
> >
> > The above example was found here:
> >
> > http://www.w3schools.com/sql/sql_join_inner.asp
>
> First and most important, a "FROM" clause is required for every
> "SELECT" command [1].  So the statement, whatever it's meant to do,
> definitely needs to be "FROM" something.  There's only two tables used
> in the example, so it would have to be "FROM Customers" or "FROM
> Orders".
>
> The "FROM" clause tells you which table forms the lines of the result.
> So if you see "FROM Customers" then you expect each row of the result
> to be referring to one Customer, with as many rows returned as there
> are Customers.  The alternative would be a SELECT where each row of the
> result referred explicitly to one Order, with as many rows returned as
> there are Orders.
>
> The difference comes to the fore when the two numbers are different.
> So imagine a case where you have three customers who have placed,
> between them, ten orders.  Do you want your SELECT to return three rows
> or ten rows ?  That tells you which table should be named in the "FROM"
> clause.
>
> Simon.
>
> [1] Okay, SQLite does a few useful things without it.  Minor
> exceptions.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
CONFIDENTIALITY, EXPORT CONTROL AND DISCLAIMER NOTE:This e-mail and any 
attachments are solely for the use of the addressee and may contain information 
that is privileged or confidential. Any disclosure, use or distribution of the 
information contained herein is prohibited. In the event this e-mail contains 
technical data within the definition of the International Traffic in Arms 
Regulations or Export Administration Regulations, it is subject to the export 
control laws of the U.S.Government. The recipient should check this e-mail and 
any attachments for the presence of viruses as L-3 does not accept any 
liability associated with the transmission of this e-mail. If you have received 
this communication in error, please notify the sender by reply e-mail and 
immediately delete this message and any attachments.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to