Self Join Venn Diagram
I thought ligaya turmelle s post on sql joins was a great primer for novice developers.
Self join venn diagram. The sql self join is used to join a table to itself as if the table were two tables. Inner join left join right join outer join left excluding join right excluding join outer excluding join while providing examples of each. Illustration inner shaded region of venn diagram represents rows that satisfies joining condition hence it is knows as inner join. And that is exactly why it is called a self join because of the fact that it s just the same table being joined to another copy of itself.
Point of interest employee job. The easiest and most intuitive way to explain the difference between these four types is by using a venn diagram which shows all possible logical relations between data sets. However it fills the columns of the right table basket b with null. Descriptions and examples of inner joins left joins right joins and outer joins.
The way you should visualize a self join for a given table is by imagining that a join is performed between two identical copies of that table. T1 and t2 are different table aliases for the same table. Inner left right and full. In this tutorial we will use the well known northwind sample database.
11 oct 2007 a visual explanation of sql joins. Instead of inner join you can use join also both are same. There are four basic types of sql joins. A self join is a regular join but the table is joined with itself.
This ppt describes sql joins in a visual manner using venn diagram. In this article i am going to discuss seven different ways you can return data from two relational tables. However like the commenters to her post i found that the venn diagrams didn t quite match the sql join syntax reality in my testing. In case the values do not equal the left join also creates a new row that contains columns from both tables and adds it to the result set.
The basic syntax of self join is as follows select a column name b column name. The following venn diagram illustrates the left join. Temporarily renaming at least one table in the sql statement. See the row 3 and 4 in the result set.
Since sql joins appear to be set based the use of venn diagrams to explain them seems at first blush to be a natural fit. Select column name s from table1 t1 table1 t2 where condition. This is just a simple article visually explaining sql joins. A self join is basically when a table is joined to itself.