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 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;
Output of SQL 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;
Output 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;
Output 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;
Output of SQL Cross Join Statement
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
0 Comments