Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help building Query 1

Status
Not open for further replies.

Tim8w

Programmer
Apr 8, 2003
44
US
I have the following three tables:

ClassHeader
ClassID
Major

TeacherClasses
TeacherID
ClassID

StudentClasses
TeacherID
Major

I want to select all TeacherClasses where the a given Major = ClassHeader.Major
 
is this your real problem, or are those table/column names being used to disguise what you're really doing?

because if the former, i'm afraid tek-tips does not allow students on the site

if the latter, please give your real table/column names and some sample data

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
I am writing this program for a large group of non-profit seminary schools and anyway, I'll list the entire table if that helps although I doubt it will...

I realize that to get the answer I need I only need the following tables:

Table 1: ClassHeader
ClassID
ClassName
Description
Units
Major


Table 2: TeacherClasses
TeacherID
ClassID
Room
Days
Hours
Semester
Year


I want to select all TeacherClasses records where the ClassHeader.Major = "Major that I choose". Since they have ClassID in common, I know this is possible...
 
is this what you're looking for?
Code:
SELECT TeacherClasses.TeacherId
     , TeacherClasses.ClassId
     , TeacherClasses.Room
     , TeacherClasses.etc
  FROM ClassHeader
INNER
  JOIN TeacherClasses 
    ON TeacherClasses.ClassID = ClassHeader.ClassID
 WHERE ClassHeader.Major = 'BasketWeaving'

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
r937,
That worked fine! Thanks for the help. Maybe I can finish this program for them tonight because of your help!

Thanks again!
 
select t.*
FROM TeacherClasses t INNER JOIN ClassHeader c ON t.ClassID = c.ClassID
WHERE c.Major = 'Major that I choose'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top