SQL course

Soldato
Joined
22 Nov 2007
Posts
4,209
Hi guys

Following an sql course and i am onto joins. I can understand them now but i have a query about this code.

I am selecting from 2 tables but i only have to type "FROM SALES" and not the product table. I know i have called the SALESPERSON name so whats the point of the "FROM" bit if it already knows whats been called?

Hope that makes sense.

SELECT ORDER_ID, S.CUSTOMER_ID, SALESPERSON.FIRST_NAME FROM
SALES S INNER JOIN CUSTOMER C
ON S.CUSTOMER_ID = C.CUSTOMER_ID
LEFT OUTER JOIN SALESPERSON
ON S.SALESPERSON_ID=SALESPERSON.SALESPERSON_ID;
 
The from bit is specifying SALES as the main table then an inner join to CUSTOMER and an outer join to SALESPERSON.

Not sure what the question is? :)

When you say like that it makes more sense. I just thought when your selecting fields from multiple tables why don't have you have to say from x , y table. Probably just overthinking it.
 
Yeah the joins are effectively doing that. Because you have joined Customer you can use C.CustomerFieldName in your SELECT list and the same where you have Salesperson.First_Name.

Thank you i understand now.

So EA, could easily write a line of code that says at the end of Weekend league who your top scorer is in literally a couple minutes(i recognize you from fifa thread).
 
Back
Top Bottom