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
 relationship links

Author  Topic 

sambrown18
Starting Member

14 Posts

Posted - 2008-04-23 : 06:46:08
Is there a way of searching tables and linking to the relationship used.

I need to find a list of tutors and the session they teach (both available in a session table)

i then need to find the list of members that are enrolled onto each session.

In the session table the relationship allows me to view what members are on each session but i cannot find a code that allows me to see what tutors teach what session and what members attend these lessons.

I spoke to my tutor who did not offer too much help but did say it may be possible to use the "AND" function

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-23 : 07:34:20
Post your table structures to get quick and accurate soln.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-23 : 07:34:32
quote:
Originally posted by sambrown18
Is there a way of searching tables and linking to the relationship used.
Yes
quote:
Originally posted by sambrown18
I need to find a list of tutors and the session they teach (both available in a session table)
i then need to find the list of members that are enrolled onto each session.
In the session table the relationship allows me to view what members are on each session but i cannot find a code that allows me to see what tutors teach what session and what members attend these lessons.
Hard to tell without knowing anything about the table structure nor proper sample data and certainly not without expected output.
quote:
Originally posted by sambrown18
I spoke to my tutor who did not offer too much help but did say it may be possible to use the "AND" function



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sambrown18
Starting Member

14 Posts

Posted - 2008-04-23 : 08:58:20
session

sessionName, tutorLastName, roomID, StartTime

Enrolment

memberLastName, sessionName


i need to narrow it down to sessonName, roomID, StartTime, tutorLastName, memberLastName
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-04-23 : 09:10:38
SELECT
S.sessionName,
S.tutorLastName,
S.roomID,
S.StartTime,
E.memberLastName
FROM
session AS S
INNER JOIN
Enrolment AS E ON ( E.sessionName = S.sessionName )
Go to Top of Page

sambrown18
Starting Member

14 Posts

Posted - 2008-04-23 : 09:18:36
that works brilliantly thank you, could u please explain what the FROM session AS S, and the INNER JOIN enrolment AS E ON means so i can learn for future use
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-23 : 09:33:53
session is table from which you are retireving information from. s is an alias for table. INNER JOIN matches the records from both the tables based on ON condition. look into books online for getting more information on INNER JOIN and example.
Go to Top of Page
   

- Advertisement -