What is the difference between the various JOIN types of SQL?

Asked

Viewed 754 times

3

In SQL there are several types of JOIN, what is the difference between INNER JOIN, LEFT JOIN, CROSS JOIN, RIGHT JOIN and FULL JOIN?

  • 3

    You may help: http://answall.com/q/6441/6454

  • It helped, but the explanation of CROSS JOIN.

  • I understand @Bacco it would be good to close by duplicate.

  • 2

    @Florida took advantage and added the cross in mine too, so gets more complete ;) - any doubt leave comment there, I try to clarify if you can. I was stalling to put, because I had not imagined how to make the graph, but I think today I got a reasonable solution

1 answer

4


Being minimalist, and considering that A is always the table on the left, and B on the right:

Inner Join = only records linked in tables A and B

Left Join = all records of A, only the linked records of B.

Right Join = all records of B, only the linked records of A.

Cross Join = all linked records of A and B, all lines of A and all lines of B, and replicas of lines of A and B with variations between records of the same tables.

Full Join = Left Join and Right Join together. Lines that are not connected do not appear.

Links:

Full Join and Cross Join

Other joins

Browser other questions tagged

You are not signed in. Login or sign up in order to post.