SQL server is the most popular database of microsoft company which was develop in 1989. SQL stands for Structure Query Language. It is RDBMs  so in this case record is store in tabular format. It is platform dependent because it runs only on windows operating system.

Join Statement

This Statement is use to combine rows from two or more tables, based on a related column between them is knows as Join Statement.

Types

There are Four Types of SQL JOINs.

  • Inner join
  • Left outer join
  • Right outer join
  • Full outer join
SQL Join Types
SQL Join Types

SQL INNER JOIN Statement

This Statement selects records that have matching values in both tables is knows as SQL INNER JOIN Statement.

Syntax

SELECT column_name(s)

FROM table1

INNER JOIN table2

ON table1.column_name = table2.column_name;

Example of SQL INNER JOIN Statement

select * FROM personal inner join city

ON personal.city = city.cid;

Input Value of Inner Join statement

Output of SQL INNER JOIN Statement

Output Value of Inner Join statement

SQL Left Outer JOIN Statement

The SQL left Outer join returns all the values from the left table and it also includes matching values from right table, if there are no matching join value it returns Zero is knows as SQL Left Outer JOIN Statement.

Syntax

SELECT column_name(s)

FROM table1

LEFT JOIN table2

ON table1.column_name = table2.column_name;

Example of SQL Left Outer JOIN Statement

select * FROM personal left join city

ON personal.city = city.cid;

Input value of SQL Left Outer JOIN Statement

Output of SQL Left Outer JOIN Statement

Output value of SQL Left Outer JOIN Statement

SQL Right Outer JOIN Statement

The SQL right Outer join returns all the values from the rows of right table. It also includes the matcheing values from left table but if there is no matching in both tables, it returns Zero is knows as SQL Right Outer JOIN Statement.

Syntax

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

Example of SQL Right Outer JOIN Statement

select * FROM personal right join city

ON personal.city = city.cid;

Input value of SQL Right Outer JOIN Statement

Output of SQL Right Outer JOIN Statement

Output value of SQL Right Outer JOIN Statement

SQL FUll Join Statement

It returns all rows from the left table to right table with zero values in place where the join condition is not met is knows as SQL Full Join Statement.

Syntax

SELECT *  

FROM table1  

FULL OUTER JOIN table2  

ON table1.column_name = table2.column_name; 

Example of Full join Satement

select * FROM personal full join city;

SQL Cross Join Statement

Example of SQL Cross Join Statement

select * FROM personal cross join city;

Input Value of SQL Cross Join Statement

Output of SQL Cross Join Statement

output Value
next part output value

If you have any queries regarding this article or if I have missed something on this topic, please feel free to add in the comment down below for the audience. See you guys in another article.

To know more about SQL please Wikipedia click here .

Stay Connected Stay Safe, Thank you


Basic Engineer

Hey Readers! We have more than fifteen years of experience in Software Development, IoT, Telecom, Banking, Finance and Embedded domain. Currently we are actively working on Data Science, ML and AI with multiple market leaders worldwide. Happy Reading. Cheers!

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *