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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Joins?

Author  Topic 

Tototo1
Starting Member

22 Posts

Posted - 2012-02-24 : 16:13:35
Hello,

I am trying to understand what exactly a JOIN does. I get that this will put to tables together, but is there anyway of actually 'seeing' the join and what it is doing. When I try to use these and pull data, my idea of what is happening versus what is actually happening has to be different. Let's say I have a table

X
Customer CustomerID Payment
Bill 2222 $400
Dave 3333 $500

and table

Y
CustomerTag PurchaseItem
2222 Doll
2211 Truck
3333 Car


If I do a join on these tables with x.customerid = y.customertag what does this actually 'do'?

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-02-24 : 16:18:12
Take a look at this page (and the pages following that which explain different types of joins). It does a very good job of explaining, using an example almost similar to yours:http://www.w3schools.com/sql/sql_join.asp
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-25 : 11:33:04
quote:
Originally posted by Tototo1

Hello,

I am trying to understand what exactly a JOIN does. I get that this will put to tables together, but is there anyway of actually 'seeing' the join and what it is doing. When I try to use these and pull data, my idea of what is happening versus what is actually happening has to be different. Let's say I have a table

X
Customer CustomerID Payment
Bill 2222 $400
Dave 3333 $500

and table

Y
CustomerTag PurchaseItem
2222 Doll
2211 Truck
3333 Car


If I do a join on these tables with x.customerid = y.customertag what does this actually 'do'?


it will link the two tables based on the condition and then return the data which have exact matches
ie



Customer CustomerID Payment PurchaseItem
Bill 2222 $400 Doll
Dave 3333 $500 Car


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -