mudzakkir toha

What is Difference Between Left Join, Inner Join, Right Join

I have this Table:

[TEST_ALAMAT]

id_alamat id_mahasiswa alamat
1 1 Solo
2 2 Semarang
3 3 Jakarta

[TEST_MAHASISWA]

id_mahasiswa nama
1 Mudzakkir
2 Muhammad
4 Fahri

 

Please Highlight id_mahasiswa at both of table. At the sample data, TEST_ALAMAT is Left Part. It contain values 1,2,3. Then, TEST_MAHASISWA is Right Part. It contain values 1,2,4.

 

LEFT JOIN
I run this query:
Select A.*, M.* from TEST_ALAMAT A
LEFT JOIN TEST_MAHASISWA M ON A.id_mahasiswa = M.id_mahasiswa

Result

id_alamat id_mahasiswa alamat id_mahasiswa nama
1 1 Solo 1 Mudzakkir
2 2 Semarang 2 Muhammad
3 3 Jakarta NULL NULL

RIGHT JOIN

Select A.*, M.* from TEST_ALAMAT A
RIGHT JOIN TEST_MAHASISWA M ON A.id_mahasiswa = M.id_mahasiswa

id_alamat id_mahasiswa alamat id_mahasiswa nama
1 1 Solo 1 Mudzakkir
2 2 Semarang 2 Muhammad
NULL NULL NULL 4 Fahri

INNER JOIN

Select A.*, M.* from TEST_ALAMAT A
INNER JOIN TEST_MAHASISWA M ON A.id_mahasiswa = M.id_mahasiswa

id_alamat id_mahasiswa alamat id_mahasiswa nama
1 1 Solo 1 Mudzakkir
2 2 Semarang 2 Muhammad

 

FULL OUTER JOIN

Select A.*, M.* from TEST_ALAMAT A
FULL OUTER JOIN TEST_MAHASISWA M ON A.id_mahasiswa = M.id_mahasiswa

id_alamat id_mahasiswa alamat id_mahasiswa nama
1 1 Solo 1 Mudzakkir
2 2 Semarang 2 Muhammad
3 3 Jakarta NULL NULL
NULL NULL NULL 4 Fahri

Graphic Left Join

Graphic Right Join

Graphic Inner Join

Graphic Full Outer Join

IP Address: 54.161.96.239
IP Number: 916545775
ISO Country Code: US
Country Name: UNITED STATES