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

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Buy Books Online at Best Prices

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.