C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Intersect and Inner join


Posted Date: 08 Aug 2008    Resource Type: Articles    Category: General
Author: D.Jeya kumar(JK)Member Level: Diamond    
Rating: Points: 7



SQL SERVER - 2005 - Difference Between INTERSECT and INNER JOIN
INTERSECT returns any distinct values that are returned by both the query on the left and right sides of the INTERSECT operator.
Intersect will be used to intersect two or more tables and get the matching rows for both the tables. For that both the tables the order of the columns should have common columns to match.
INTERSECT operator in SQL Server 2005 is used to get the matched records from both the left and the right query of the Intersect Operator. INTERSECT operator returns almost same results as INNER JOIN clause many times.
Both intersect and inner join can be used for commonly used in some places.
Let us see an example to understand better.
SELECT * FROM userdomain WHERE UserID IN (4,6,7)
INTERSECT
SELECT * FROM * FROM userdomain WHERE UserID IN (4,6,10)
Result will be userid which common in both the places.
Inner join will be used to retrieve value which is common to both the tables. In Inner joins by default it will return the duplicate values also where as in intersect it will show the default values.
For Ex:
SELECT d.Userid,d.domainid FROM UserTable u
INNER JOIN Domaintable d ON u.Userid = d.Userid

In inner join also we can avoid duplicate by use distinct keyword to void duplicate values and inner joins with distinct keyword will avoid duplicate values.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Connect to an excel file as a data source via OBDC
Previous Resource: Host a WPF control in a windows application
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use