Get Started: SQL JOINS

In This Article, You Will Know About SQL JOINS. 

SQL JOINS – Before moving ahead, let’s know a bit about SQL Aliases.

Table of Contents

SQL JOIN

The SQL JOIN clause is used to add two or more tables based on common values between them in rows & columns. 

SYNTAX

				
					SELECT TABLE.COLUMN(S)
FROM TABLE
INNER JOIN TABLE ON CONDITION(S)
				
			

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 JOIN clause to add the tables based on common values in rows & columns.

				
					SELECT Data_1.S.No, Data_1.Name, Data_2.Section_ID 
FROM Data_1
INNER JOIN Data_2 ON Data_1.S.No = Data_2.S.No;
				
			

As a result, it returns a table after combining common data based on both tables.

S.No

Name

Section_ID

1

Alex

A

2

Rolex

B

3

Salex

C

4

Jalex

D

5

Kalex

E

Different Types of SQL JOINs

Here are the different types of the JOINs in SQL:

INNER JOIN – It returns the common records from both tables.

LEFT JOIN – It returns all records from the left table and common records from the right table.

RIGHT JOIN – It returns all records from the right table and common records from the left table.

FULL JOIN – It returns all records common from either the left table or the right table.

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 JOINS”

Leave a Comment

Stay in the loop

codingstreets