Understand syntax with inner join

Hi All,
I have this example:

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;

Can you please help me and tell me why the "FROM" is from "Orders" table and not also from "Customers" table ?

It is also doing a query against the Customers table . It is just another way of doing this

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders o, Customers  c
where o.CustomerID=c.CustomerID;
1 Like

INNER JOIN is an optional part of the FROM clause.

The query is against all joined tables; often there are 5 or more tables joined in a single query. The syntax has to be different, INNER JOIN / {LEFT|RIGHT} OUTER JOIN rather than FROM, because you have to "tell" SQL how to join the tables.

Thank you very much

Thank you very much!

Thank you very much. So can you please write the syntax of what you mean ?

SELECT ...
FROM first_table
INNER JOIN second_table ON ...
LEFT OUTER JOIN third_table ON ...
and so on.

The INNER / LEFT / RIGHT are required because you have to "tell" SQL how you want to join the tables. There could be big differences in the results between an INNER and OUTER join, so SQL needs to "know" which one you mean.

Thanks!!