Get Started: SQL RIGHT JOIN

In This Article, You Will Know About SQL RIGHT JOIN. 

SQL RIGHT JOIN – Before moving ahead, let’s know a bit about SQL LEFT JOIN.

Table of Contents

SQL RIGHT JOIN

The SQL RIGHT keyword returns all records from the right table and match answers from the left table. RIGHT JOIN is also known as RIGHT OUTER JOIN.

Syntax

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

Example Database

Table name: Data_1

S.No

Name

Class

1

Alex

5

2

Rolex

6

3

Salex

7

4

Jalex

8

5

Kalex

9

Table name: Data_2

S.No

Roll_No

Section_ID

6

451

A

7

452

B

8

453

C

9

454

D

10

455

E

Example: Use the SQL RIGHT JOIN keyword to return the matching records from the table.

				
					SELECT Data_1.Name, Data_2.Roll_No
FROM Data_1
RIGHT JOIN Data_2
ON Data_1.S.No = Data_2.S.No;
				
			

Example: Use the SQL RIGHT JOIN keyword to return the matching records from the table ordered by Section_ID.

				
					SELECT Data_1.Name, Data_2.Roll_No
FROM Data_1
RIGHT JOIN Data_2
ON Data_1.S.No = Data_2.S.No
ORDER BY Data_2.Section_ID;
				
			

If you find anything incorrect in the above-discussed topic and have further questions, please comment below.

Connect on:

1 thought on “Get Started: SQL RIGHT JOIN”

Leave a Comment

Stay in the loop

codingstreets