Original Datasets

Database A

 

Database B

ID

Fruit

 

ID

Vegetable

1

Apple

 

3

Lettuce

2

Pear

 

4

Carrot

3

Orange

 

5

Celery

4

Lemon

 

6

Broccoli

The four main types of joins, and their resulting output datasets, are shown below.

Inner Join

Database Join
IDFruitVegetable
3OrangeLettuce
4LemonCarrot

Left Join

Database Join
IDFruitVegetable

1

Apple

Null

2

Pear

Null

3OrangeLettuce
4LemonCarrot
 

Right Join

Database Join
IDFruitVegetable
3OrangeLettuce
4LemonCarrot

5

NullCelery
6NullBroccoli
 

Full Join 

Database Join
IDFruitVegetable

1

Apple

Null

2

Pear

Null

3OrangeLettuce
4LemonCarrot

5

NullCelery
6NullBroccoli