Cara has a lot of material on this, but this image I sent as a comment will help you better.
Basically you have to understand the concept of left and right (left e right
), for example:
Your table in FROM it is your table esquerda
, that is to say, left
, when doing a JOIN.
FROM tabela1 X
LEFT OUTER JOIN tabela2 Y ON Y.campo1 = X.campo2
I mean, you’re bringing everything from table X, plus the Y records that link to X.
Now in:
FROM tabela1 X
RIGHT OUTER JOIN tabela2 Y ON Y.campo1 = X.campo2
You bring everything that’s on your table direita
"Y" plus "X" that has to do with "Y".
INNER only what is common in the 2 tables, and FULL brings EVERYTHING regardless of relationships.
Best way to understand: https://i.stack.Imgur.com/1UKp7.png
– rbz
Best link to understand this https://answall.com/questions/6441/qual-%C3%A9-a-difference%C3%A7a-entre-Inner-Join-e-outer-Join
– Allan Kehl