SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how sql doing inner join
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

harshiloh
Starting Member

1 Posts

Posted - 05/03/2012 :  07:52:09  Show Profile  Reply with Quote
1.)please explain the algorithm of sql inner join,

2.)
User table (20 core user)
ID,Name,CityId

City table (1 lakh city)
Id,Name,CountryId

select * from User inner join City on User.CityId=City.Id
select * from City inner join User on User.CityId=City.Id

which one is better ?why?

robvolk
Most Valuable Yak

USA
15559 Posts

Posted - 05/03/2012 :  09:17:39  Show Profile  Visit robvolk's Homepage  Reply with Quote
1. There are 3 types, nested loops, merge, and hash joins. More info on them here:

http://www.sql-server-performance.com/2010/pysical-join-operators/
http://msdn.microsoft.com/en-us/library/ms173815.aspx

2. Neither one is better, they're exactly the same query and will return the same results.
Go to Top of Page

DonAtWork
Flowing Fount of Yak Knowledge

2111 Posts

Posted - 05/03/2012 :  11:43:08  Show Profile  Reply with Quote
Rob: I have an interview coming up. Can you go take it for me? kthksbye!











How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

robvolk
Most Valuable Yak

USA
15559 Posts

Posted - 05/03/2012 :  12:18:06  Show Profile  Visit robvolk's Homepage  Reply with Quote
quote:
Originally posted by DonAtWork

Rob: I have an interview coming up. Can you go take it for me? kthksbye!
Sure! How much are they offering?
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.05 seconds. Powered By: Snitz Forums 2000