Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 10th, 2002, 03:03 PM
rob5408 rob5408 is offline
Certified Genius
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: over there
Posts: 77 rob5408 User rank is Private First Class (20 - 50 Reputation Level)rob5408 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 46 m 57 sec
Reputation Power: 12
Send a message via AIM to rob5408
joining tables across mulitiple columns

If I have two tables (Members, Teams) with Teams having multiple foreign keys to the Members table how would go about selecting each team and getting the members names into the recordset as well. for example

--- Members --__----------- Teams ---------
ID_Name______ID_Member1_Member2
1__Rob_______1__1_______2
2__Tom_______2__3_______4
3__Jim
4__Dave


And I wanna return from a query...
TeamID__Member1__Member2
1_______Rob______Tom
2_______Jim_______Dave

What combinations of joins, subqueries, etc would I have to use in order to get that result??? Thanks, rob

Last edited by rob5408 : July 10th, 2002 at 03:06 PM.

Reply With Quote
  #2  
Old July 10th, 2002, 07:51 PM
Waltjp's Avatar
Waltjp Waltjp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: NJ, USA
Posts: 91 Waltjp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 1 m 8 sec
Reputation Power: 12
Is this your complete table structure? Just 2 members per team?
__________________
- Walt

Will code for food.

Reply With Quote
  #3  
Old July 10th, 2002, 09:28 PM
rob5408 rob5408 is offline
Certified Genius
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: over there
Posts: 77 rob5408 User rank is Private First Class (20 - 50 Reputation Level)rob5408 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 46 m 57 sec
Reputation Power: 12
Send a message via AIM to rob5408
well actually it is 4 members but just as an example i showed two

Reply With Quote
  #4  
Old July 11th, 2002, 04:06 PM
Waltjp's Avatar
Waltjp Waltjp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: NJ, USA
Posts: 91 Waltjp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 1 m 8 sec
Reputation Power: 12
The would be much easier if you had 3 tables.


Members_Table
MemID (Primary Key)
FirstName
LastName
Address
etc.

Teams_Table
TeamID (Primary Key)
TeamName

Roster_Table
TeamID (Foreign Key)
MemID (Foreign Key)

You could then just select the MemID and TeamID from the Roster_Table. No joins. No subqueries. Just a simple select.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > joining tables across mulitiple columns

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap