Difference between INNER JOIN, JOIN and WHERE? [duplicate]

3

I need to make a query that returns information according to a given condition, I've always used Where because I did not know if I could use another method. So what's the difference between Where , Inner Join and Join . Can I use it when each one of them?

If you can give examples. Thanks.

    
asked by anonymous 20.10.2017 / 17:40

1 answer

6

Dude has a lot of stuff on it, but this image I submitted 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 is its esquerda table, that is, left , when making a JOIN.

FROM tabela1 X
LEFT OUTER JOIN tabela2 Y ON Y.campo1 = X.campo2

That is, you are bringing everything from the X table, plus the Y records that have binding to the X.

Now in:

FROM tabela1 X
RIGHT OUTER JOIN tabela2 Y ON Y.campo1 = X.campo2

You put everything on your table of direita "Y" plus those of "X" that have a relation with "Y".

The INNER only what is in common in the 2 tables, and the FULL back EVERYTHING independent of the relations.

    
20.10.2017 / 18:09