Joins
Join syntax of SQL allows you to connect two database tables which share a column value. On most occasions, the shared columns constitute foreign key relation between two tables but having such relationship is not mandatory. As long as the columns hold the value referring to the same record, you can run a meaningful join query. For instance, in our domain, the Employee
table's Id
column and the Benefit
table's Employee_Id
column hold the Id of particular employee record. We can join the two tables using value in those two columns.
Different types of joins
There are mainly two types of joins. An inner join and an outer join. The best way to understand the difference between the two is to use Venn diagram from set theory. If you think of employee as one set and benefit as another set, then intersection between the two can be represented by a Venn diagram as follows:
The overlapping area or intersection of the Employee and Benefit sets represents the records that are present in both sets...