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
 how sql doing inner join

Author  Topic 

harshiloh
Starting Member

1 Post

Posted - 2012-05-03 : 07:52:09
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

15732 Posts

Posted - 2012-05-03 : 09:17:39
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
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2012-05-03 : 11:43:08
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

15732 Posts

Posted - 2012-05-03 : 12:18:06
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
   

- Advertisement -