Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 10079 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > SQL Server > JOINS IN SQL SERVER WITH EXAMPLE ...
Sriramnandha

JOINS IN SQL SERVER WITH EXAMPLE

 Code Snippet posted by: Sriramnandha | Posted on: 5/23/2012 | Category: SQL Server Codes | Views: 565 | Status: [Member] | Points: 40 | Alert Moderator   


DEFINATION:

JOINS ACTUALY PERFORMS ACTUALY TWO ORE MORE TABLES COMBINED INTO A SINGLE RESULT SET.TO COMBINE DIFFERENT TABLES,TWO OR MORE DATABASE ,DIFFERENT SERVERS.

THERE ARE FOUR TYPES OF JOINS AVAILABLE IN SQL SERVER

1) INNER JOIN
2) OUTER JOIN(LEFT OUTER JOIN,RIGHT OUTER JOIN)
3) FULL JOIN.
4) CROSS JOIN
5) SELF JOIN

INNER JOIN:

TWO TABLE HAVING COMMON COLUMN VALUES GO WITH INNER JOIN

SELECT * FROM <TABLE1> INNER JOIN <TABLE2> ON TABLE1.COLUMNNAME=TABLE2.COLUMNNAME



OUTER JOIN:

OUTER JOIN HAS TWO SUB TYPES LEFT OUTER JOIN AND RIGHT OUTER JOIN

LEFT OUTER JOIN:

SELECT * FROM TABLE1 LEFT OUTER JOIN TABLE2 ON TABLE1.COLUMNNAME=TABLE2.COLUMNNAME WHERE COLUMNNAME='XYX'


RIGHT OUTER JOIN:

SELECT * FROM TABLE1 RIGHT OUTER JOIN TABLE2 ON TABLE1.COLUMNNAME=TABLE2.COLUMNNAME



FULL JOIN:

COMBINE WITH LEFT OUTER JOIN AND RIGHT OUTER JOIN

SELECT * FROM TABLE1 FULL JOIN TABLE2 ON TABLE1.COLUMNNAME=TABLE2.COLUMNNAME



CROSS JOIN:

CROSS JOIN IS AN CARTESIAN PRODUCT CROSS JOIN CANNOT USE WHERE CONDITION

SELECT * FROM TABLE1 CROSS JOIN TABLE2

REGARDS





sriram
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/20/2013 12:57:03 AM