.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> SQL Query >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

JOINS IN SQL SERVER

Posted By:sriram       Posted Date: October 28, 2011    Points: 40    Category: SQL Query    URL: http://www.dotnetspark.com  

JOIN IN SQL SERVER
 

JOINS ACTUALY PERFORMS TWO OR MORE TABLES COMBINED INTO  A SINGLE RESULT SET.

THERE ARE FOUR TYPES OF JOINS AVAILALBE IN SQLSERVER

1) INNER JOIN

2) OUTER JOIN(LEFT OUTER JOIN,RIGHT OUTER JOIN)

3) FULL JOIN

4) CROSS JOIN

5) SELF JOIN

EXAMPLES:

INNSER JOIN:

SELECT * FROM EMPDETAILS INNER JOIN EMPSALARY ON EMPDETAILS.EMPID=EMPSALARY.EMPID

 

OUTER JOIN :

LEFT OUTER JOIN:

SELECT * FROM EMPDETAILS LEFT OUTER JOIN EMPSALARY ON EMPDETAILS.EMPID=EMPSALARY.EMPID

RIGHT OUTER JOIN:

SELECT * FROM EMPDETAILS RIGHT OUTER JOIN EMPSALARY ON EMPDETAILS.EMPID=EMPSALARY.EMPID

CROSS JOIN:

SELECT * FROM EMPDETAILS CROSS JOIN EMPSALARY

SELF JOIN:

SELECT EMPID A ,EMPNAME B FROM EMPDETAILS A ,EMPSALARY B

WHERE A.EMPID=B.EMPID

 


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend