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