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
 LEFT join or INNER join
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

insanepaul
Posting Yak Master

178 Posts

Posted - 11/12/2010 :  10:18:54  Show Profile  Reply with Quote
When you join tables what goes through your mind when you consider it should be a LEFT join or INNER join in a professional environment? What are the steps?

TimSman
Posting Yak Master

USA
127 Posts

Posted - 11/12/2010 :  10:37:20  Show Profile  Reply with Quote
Depends on what you want to accomplish.

If I know I want all the data from one table, regardless of anything else, the other tables are left joins. This is for "informational display". If I'm actually filtering records out based on specific qualifiers, it's an inner join.

First step is to identify your "base" table. Seems easy, but it's not always the most obvious.
Go to Top of Page

insanepaul
Posting Yak Master

178 Posts

Posted - 11/12/2010 :  10:44:39  Show Profile  Reply with Quote
quote:
Originally posted by TimSman

Depends on what you want to accomplish.

If I know I want all the data from one table, regardless of anything else, the other tables are left joins. This is for "informational display". If I'm actually filtering records out based on specific qualifiers, it's an inner join.

First step is to identify your "base" table. Seems easy, but it's not always the most obvious.



Yeah, that was the next question I was going to ask. Which table does one start off with
Go to Top of Page

TimSman
Posting Yak Master

USA
127 Posts

Posted - 11/12/2010 :  10:56:02  Show Profile  Reply with Quote
I'd say it depends on a lot of factors. What are you trying to accomplish? What's your basic architecture? Are there aggregates? I'd say all of that weighs in. And if you don't like the way things are going, go back and start over.
Go to Top of Page

insanepaul
Posting Yak Master

178 Posts

Posted - 11/12/2010 :  11:11:42  Show Profile  Reply with Quote
quote:
Originally posted by TimSman

I'd say it depends on a lot of factors. What are you trying to accomplish? What's your basic architecture? Are there aggregates? I'd say all of that weighs in. And if you don't like the way things are going, go back and start over.


For a novice like me then it's very difficult to know what table to begin with without having some rules. I'm thinking that the base table is where most of the columns you want. Lets say 5 from table A and 1 or 2 each from all the other tables. What do you mean by basic architecture? What are aggregates in SQL? Are they dictionary tables? Does the size of the table matter? If table A connects 1-1 to 5 other tables then should that be the one to start with? Does it really matter which one we start with as they are all linked or does it affect performance by choosing the right one.
Go to Top of Page

ahmeds08
Aged Yak Warrior

India
690 Posts

Posted - 11/14/2010 :  01:15:12  Show Profile  Send ahmeds08 a Yahoo! Message  Reply with Quote
u can also go with inner join when u want to eliminate null records.if iam not wrong.
Go to Top of Page

jessiefun
Starting Member

35 Posts

Posted - 11/15/2010 :  01:20:50  Show Profile  Reply with Quote
Yeah, I agree with Tim. And now you need is to create two tables and make some practice. Then you will totally understand.
Good luck.
Regards, Jessie
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.08 seconds. Powered By: Snitz Forums 2000