+ 1
Defining items for WHERE in SQL
SELECT customers.ID, customers.Name, orders.Name, orders.Amount FROM customers, orders WHERE customers.ID=orders.Customer_ID ORDER BY customers.ID; Above is the code from Joining Tables in the SQL course... Why does orders.Customer_ID not need to be in the SELECT as well? I completed the lesson but fear I may missed the boat on this particular section.
3 odpowiedzi
+ 3
what you write in the SELECT is basically what you will see as result. In the FROM statement you write the parameters of your search. I’m happy I have been helpful!
+ 3
Because you are not looking for orders.Customer_ID. You are just finding a match. The script is looking for the ID in the customers table that matches the Customer_ID in the orders table and not the customer_ID itself.
0
Ah, ok. I was thinking of the SELECT like defining a variable. But I guess mentioning a table in FROM pulls in the whole table... That's really neat and a lot cleaner. Thanks!