I know you have to specify from so the server knows where you are trying to pull this information from, and it's the first thing the server looks at, but look at the following (or any join statement) example:
SELECT employees.Lastname, employees.Firstname, invoices.Sale, invoices.Price
FROM employees
LEFT JOIN invoices
ON employees.id = invoices.EmployeeID
The user already specifies the tables in the SELECT statement in employees.Lastname, employees.Firstname, invoices,Sales, and invoices.Price tables. Why do you have to put in FROM employees? The reason I ask is because this is slightly confusing. Why not pick:
FROM invoices? Why specify FROM employees instead?
-Can you do a JOIN statement from 3 or more tables? If so, what table do you pick in the FROM line?
Thanks in advance for my newb questions! I am trying to learn SQL as well as I can, so I might bug you guys with more if that's ok.
SELECT employees.Lastname, employees.Firstname, invoices.Sale, invoices.Price
FROM employees
LEFT JOIN invoices
ON employees.id = invoices.EmployeeID
The user already specifies the tables in the SELECT statement in employees.Lastname, employees.Firstname, invoices,Sales, and invoices.Price tables. Why do you have to put in FROM employees? The reason I ask is because this is slightly confusing. Why not pick:
FROM invoices? Why specify FROM employees instead?
-Can you do a JOIN statement from 3 or more tables? If so, what table do you pick in the FROM line?
Thanks in advance for my newb questions! I am trying to learn SQL as well as I can, so I might bug you guys with more if that's ok.