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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 joins?

Author  Topic 

sqlclarify
Yak Posting Veteran

56 Posts

Posted - 2008-10-17 : 01:25:54
I have 4 tables.

A, B, C, and E which have been joined via their keys.

I want to join another table Q to these joined tables. But according to the keys I can join Q to B, C, or E. How do I decide whether to join Q to B, C, or E?

Jawad Khan
Starting Member

21 Posts

Posted - 2008-10-17 : 02:22:49
This is totally a matter of design and business rules. Which table to join, depends upon the scenario you are working in.
Go to Top of Page

rammohan
Posting Yak Master

212 Posts

Posted - 2008-10-17 : 02:52:39
Its all depends on your rules of u r project. but take care about forming loops when u r joining tables like a->b->c->a

One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

Go to Top of Page

mmqsql
Starting Member

2 Posts

Posted - 2008-10-17 : 22:17:36
could you please give me a minor example about how it depends on rules?

Thank you!
Go to Top of Page

ForkandBeard
Starting Member

10 Posts

Posted - 2008-10-18 : 07:23:30
Like all have said. You really need to give us more details but sometimes, where multiple joins are valid, starting with the table with the fewest results doesn't hurt, as it may improve efficiency.

Many Thanks
Mitchell
www.forkandbeard.co.uk
Go to Top of Page

malaytech2008
Yak Posting Veteran

95 Posts

Posted - 2008-10-18 : 13:07:24
As all said, first four tables u joined using keys.
Fifth table u can join directly to Q from any of the three table.
It does not make difference, if Q contains records having one-to-one relationship with other three table.Otherwise u make ur choice according to B rules.

Thanks
Malay

malay
Go to Top of Page

sqlclarify
Yak Posting Veteran

56 Posts

Posted - 2008-11-07 : 01:15:54
Can you lead me to an article online or a book or something which would demonstrate this and explain this to me please?

(P.S. I did try searching online, could not find anything which answers my question, the reason why I asked)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-07 : 01:42:04
see this. quite a lot of articles on joins
http://weblogs.sqlteam.com/jeffs/category/248.aspx
Go to Top of Page
   

- Advertisement -