| Author |
Topic |
|
sqldba75
Starting Member
1 Post |
Posted - 2007-11-02 : 10:34:55
|
| Hi,I am new to sql programming.please let me know what is difference between the inner join,outer join.which one is the fast?why?Thanks,dba75 |
|
|
anonymous1
Posting Yak Master
185 Posts |
Posted - 2007-11-02 : 11:06:37
|
| sql server books online, would be a great place to learn about the different joins. here is a link in case you did not install it locally, YEThttp://msdn2.microsoft.com/en-us/library/ms191517.aspxwithout specifics, the inner join returns the fewest rows and would therefore be the fastest |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2007-11-02 : 11:17:21
|
2nd opinion - same as the first One of the best things you can do to get started with sql server is start getting familiar with their "help". It can be installed with Sql Server and it is also available online: http://msdn2.microsoft.com/en-us/library/ms130214.aspxbetween the reference and tutorials you can learn at all levels. FROM topic is one place that defines the join types.http://msdn2.microsoft.com/en-us/library/ms177634.aspxas to your second question:Speed would not be the factor in determining which join type to use as they accomplish different things.Be One with the OptimizerTG |
 |
|
|
arorarahul.0688
Posting Yak Master
125 Posts |
Posted - 2007-11-03 : 07:29:16
|
| joins areof two types as u asked inner and outer inner join are used to fetch data common to both tableslikeselect a.col1,b.col2 from table first a inner join table second b where a.<col_common to both >=b.<col common to both tables> only those records will be fetch those are having common values for the col. taken for join firstcol1 col2 col31 q w2 w e 3 w e4 w esecondcol1 col2 col31 a s2 b sresult for the inner join is col1 col21 a2 bin outer join its not same as in inner join here data will be taken completely from one of two tables andcommon data from the second tablelikeselect a.col1,b.col2 from table first a left outer join table second b where a.<col_common to both >=b.<col common to both tables>this fetch all entries corresponding to col1 from table first and only matching entries from table secondlikecol1 col21 q2 w3 w4 w1 a2 bsimilarly right outer join will fetch all data from table second and matching data from table firstRahul Arora MCA 07 BatchNCCE Israna, PanipatHRY, INDIA######################IMPOSSIBLE = I+M+POSSIBLE |
 |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2007-11-03 : 08:39:14
|
| Inner joins only brings in records from both joined tables where all records match (based on the joining columns)Outer joins bring in all records from the "outer" table and only records from the other table where there are matching records on the joining columns. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-11-03 : 08:50:32
|
quote: Originally posted by arorarahul.0688 joins areof two types as u asked inner and outer inner join are used to fetch data common to both tableslikeselect a.col1,b.col2 from table first a inner join table second b ]whereon a.<col_common to both >=b.<col common to both tables> only those records will be fetch those are having common values for the col. taken for join firstcol1 col2 col31 q w2 w e 3 w e4 w esecondcol1 col2 col31 a s2 b sresult for the inner join is col1 col21 a2 bin outer join its not same as in inner join here data will be taken completely from one of two tables andcommon data from the second tablelikeselect a.col1,b.col2 from table first a left outer join table second b whereon a.<col_common to both >=b.<col common to both tables>this fetch all entries corresponding to col1 from table first and only matching entries from table secondlikecol1 col21 q2 w3 w4 w1 a2 bsimilarly right outer join will fetch all data from table second and matching data from table firstRahul Arora MCA 07 BatchNCCE Israna, PanipatHRY, INDIA######################IMPOSSIBLE = I+M+POSSIBLE
MadhivananFailing to plan is Planning to fail |
 |
|
|
arorarahul.0688
Posting Yak Master
125 Posts |
Posted - 2007-11-06 : 08:16:45
|
quote: Originally posted by madhivanan
quote: Originally posted by arorarahul.0688 joins areof two types as u asked inner and outer inner join are used to fetch data common to both tableslikeselect a.col1,b.col2 from table first a inner join table second b ]whereon a.<col_common to both >=b.<col common to both tables> only those records will be fetch those are having common values for the col. taken for join firstcol1 col2 col31 q w2 w e 3 w e4 w esecondcol1 col2 col31 a s2 b sresult for the inner join is col1 col21 a2 bin outer join its not same as in inner join here data will be taken completely from one of two tables andcommon data from the second tablelikeselect a.col1,b.col2 from table first a left outer join table second b whereon a.<col_common to both >=b.<col common to both tables>this fetch all entries corresponding to col1 from table first and only matching entries from table secondlikecol1 col21 q2 w3 w4 w1 a2 bsimilarly right outer join will fetch all data from table second and matching data from table firstRahul Arora MCA 07 BatchNCCE Israna, PanipatHRY, INDIA######################IMPOSSIBLE = I+M+POSSIBLE
MadhivananFailing to plan is Planning to fail
thanks for correctionRahul Arora MCA 07 BatchNCCE Israna, PanipatHRY, INDIA######################IMPOSSIBLE = I+M+POSSIBLE |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-11-06 : 08:32:43
|
| How is it that people get DBA jobs in this industry and they have never heard of Google? How is that possible? (I am being sincere and serious, not sarcastic ....)- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-11-06 : 08:36:48
|
quote: Originally posted by jsmith8858 How is it that people get DBA jobs in this industry and they have never heard of Google? How is that possible? (I am being sincere and serious, not sarcastic ....)- Jeffhttp://weblogs.sqlteam.com/JeffS
May be the OP a fresher? I have seen the experienced DBAs also struggling to write queriesMadhivananFailing to plan is Planning to fail |
 |
|
|
|