the first
course,,,,,,,,,,,,have course_id(PK) ,course_name ....
the second
class,,,,,,,,,,,,,have class_id(PK) , course_id(FK) , class# ....
the third
class time,,,,,,have time_id(PK) , class_id(FK) , start , end , day ....
i want to select in one statement all of the :
course_name , class# , start , end , day
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Jignesh TrivediRank #16 · 50.3K reputationPosted May 24, 2012, 7:30 PM EDT
After SQL server 2000 the best practices is use inner join or outer join.
SELECT cu.course_name,cs.class#,ct.start,ct.end,ct.day
FROM course cu
INNER JOIN class cs ON cs.course_id=cu.course_id
INNER JOIN classtime ct ON ct.class_id=cs.class_id
Also Depending on Relation of these table use can use Right Outer or Left outer.
hope this will help u.
V S N Raju KanumuriRank #8,839 · 215 reputationPosted May 24, 2012, 6:52 PM EDT
try this join query
select cu.course_name,cs.class#,ct.start,ct.end,ct.day from course cu,class cs,classtime ct where ct.class_id=cs.class_id and cs.course_id=cu.course_id
SenthilkumarRank #387 · 6.5K reputationPosted May 24, 2012, 8:02 PM EDT
There are three tables in your list.
You need to use the join to combine the three table results.
Here in the first table, you have the course_id which also exists in the second table.
table1.course_id = table2.course_id
table2.class_id = table3.class_id
Use the inner join to combine the result set.