Left join in SQL and DBMS

Left join in SQL and DBMS

Left join shows all rows from the left table and shows only matching rows from the right table.

RegistrationNo Marks
T4Tutorials1 77
T4Tutorials2 32

Table: Exams

Inner join shows results from both tables where there is any match between columns in both tables.

RegistrationNo Fee
T4Tutorials1 1000
T4Tutorials2 2000
T4Tutorials3 3000

Table: Accounts

Now, we have two different tables. If we want to show the record of both tables in one single table then we can use a left join to join both two tables.

Query of left join

SELECT Exams.RegistrationNo, Exams.Marks, Accounts.Fee FROM Exams LEFT JOIN Accounts ON Exams.RegistrationNo =  Accounts.RegistrationNo

RegistrationNo Marks Fee
T4Tutorials1 77 1000
T4Tutorials2 32 2000

Table: Table generated after Left Join

 

Test Your Understandings

1. Left join shows some rows from left table ? YES / NO

Answer - Click Here:
No, its show all rows

2. Left join shows all rows from Right table? YES / NO

Answer - Click Here:
No, it can only show matching rows from right table.

3. SELECT Exams.Marks, Accounts.Fee FROM Exams LEFT JOIN Accounts?

In this query, exams are the right table and accounts is the left the table.

Yes/No

Answer - Click Here:
No, exams is left table

Topic Covered

Left join in SQL and DBMS.

By: Prof. Fazal Rehman Shamil    CEO @ T4Tutorials.com
Whatsapp: +92 302 87 000 85     Facebook: For Discussions