Can someone explain step by step how this query is processed?
SELECT F.ID,
F.FirstName,
h.UserID,
h.TYPE,
L.UserID,
L.LOGGEDIN
FROM users AS F
INNER JOIN history AS h
ON h.USERID = F.ID
LEFT JOIN Login AS L
ON L.USERID = f.MONEY
If i remove the L.UserID, L.LOGGEDIN and LEFT JOIN it gives me this result:
SELECT F.ID,
F.FirstName,
h.UserID,
h.TYPE
FROM users AS F
INNER JOIN history AS h
ON h.USERID = F.ID
ID FirstName UserID TYPE
6 rafal 6 A
6 rafal 6 A
6 rafal 6 A
5 rafal 5 B
Does it mean that the result is returned by the INNER Join in the very first step and it is further LEFT Joined?
Yes. You could also write the
FROMpart of the query as:if that helps you. This is how the
FROMpart is parsed.Now the order or processing is first the
FROMclause, then theSELECT. For more complicated queries it’s:Notice that is does not mean that the DBMS will process the query in this order. It can choose to take a different path. No matter how it processes it though, the result set should be the same as if it was processed this way.