Left Join

Advertisements

Inner Join in SQL Right Join in SQL

Left Join

Left Join return all rows from the right table, and the matched rows from the left table.

left join

The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the left table (table1). The result is NULL in the left side when there is no match.

Syntax

	
SQL RIGHT JOIN Syntax
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name=table2.column_name;

or

Syntax

	
SELECT column_name(s)
FROM table1
RIGHT OUTER JOIN table2
ON table1.column_name=table2.column_name;

Note: In some databases Left JOIN is called Left OUTER JOIN.

Employee table

Emp_idNameAge
101Amit Sukla24
102Rahul jain34
103Sultan Alam54
104Gaurav rawat26
105Hitesh Kumar35

Payment table

Payment_idDateSalary
10120-01-201420000
10223-03-201445000
10312-02-201450000
10428-07-201455000
10520-11-201440000

After apply right join on these two table, result show like below;

Example

	
SELECT Employee.emp_id, Payment.Name
FROM Employee
RIGHT JOIN Payment
ON Employee.emp_id=Payment.Payment_id
ORDER BY Employee.emp_id;

In above syntax we select 2 columns, emp_id and name from table Employee and table Payment. And retrieving all rows where the employee identification number is the same in both the Employee and Payment tables.

Payment_idName
101Amit Sukla
102Rahul jain
103Sultan Alam
104Gaurav rawat
105Hitesh Kumar

Inner Join in SQL Right Join in SQL

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements