EXISTS in SQL Server

What is a SQL Join? When would you use SQL Joins?

What is a SQL Join?  When would you use Joins?
Join is used to fetch data rows from more than one tables simultaneously based on your join conditions.

Types of joins in SQL:-
1.      INNER JOIN
2.      OUTER JOIN
a.        Right Outer Join
b.        Left Outer Join
c.         Full Outer Join
3.      SELF JOIN
4.      CROSS JOIN
5.      MULTIPLE JOIN
All the Joins are work between the table’s key relations.

What is inner join in SQL? when would you use it?
Inner Join returns the matched rows from both the tables. If both the keys are matched then return rows otherwise not!

What is Left Outer Join in SQL? when would you use it?

In the LEFT OUTER JOIN, returns all the matched rows from the left table and matched rows from right table. If the right table is not matched then will return NULL values.


What is Right Outer Join in SQL? when would you use it?

In the RIGHT OUTER JOIN, returns all the matched rows from the right table and matched rows from left table. If the left table rows are not matched then return NULL values.


What is Full Outer Join in SQL? when would you use it?

FULL OUTER JOIN work between with both the LEFT OUTER and RIGHT OUTER JOINS. If the condition is matched then returns matched rows otherwise returns NULL values.


What is SELF JOIN and when would you use it?
A SELF JOIN is join which is used to join a table to itself.

There is no SELF JOIN keyword and it is used to compare values in a column with other values in the same column in the same table.

For example,

SELECT * FROM TableA t1, TableA t2
WHERE t1.Id = t2.Id


In the above query, WHERE clause could be any given expression as per you!

I hope you are enjoying with this post! Please share with you friends!! Thank you!!!


ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

www.code-sample.com/. Powered by Blogger.
^