Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How SQL works Internally?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

31 Posts

Posted - 05/15/2013 :  02:00:34  Show Profile  Reply with Quote
Hi All,

I want to write Intersect query with 3 different tables,for that purpose I wrote the following code.

select DataElement2 from test intersect select DataElement2 from test2 intersect select DataElement2 from test3

it's working fine,But I have a doubt about,is it right what I mention in below.

In my point of view the entire above query consider as a single query.Once we send the query to SQL,I think SQL understood as Three queries.

Is it right,What I am this I want to know If we use Joins between different tables.How SQl will understood.

I hope,you understand my question.

Fell Free,If you want to edit my question.

Thank you.

Edited by - grandhi on 05/15/2013 02:03:42

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 05/15/2013 :  02:09:42  Show Profile  Reply with Quote
The query engine will break it down into individual queries, fetch result for each and then apply intersect operator over them to give you the common values present.
In comparison, in a join the query engine fetches all the records from involved tables based on join condition and give you merged result

To get exact sequence you can run the query with "display actual execution plan" option on on SSMS and it will give you graphical representataion of actual query plan used in query.

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000