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 2000 Forums
 Transact-SQL (2000)
 stored procedure question?

Author  Topic 

mshen
Starting Member

8 Posts

Posted - 2004-08-17 : 09:45:47
Hi,

I have two tables.

table one (total student table)

id student_id
1 10
2 11
3 12
4 13
5 14

table two (course/student table)

id course_id student_id
1 1 10
2 1 12
3 2 10
4 2 11

(one student maybe take many courses)

I need to get the student who do not take
course two(course_id<>2).

Please give me a idea how to write the stored procedure.

Thanks a lot.

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-08-17 : 09:48:26
Look. It's the same homework again. :)

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-08-17 : 09:56:51
here goes a wild guess :))

select t1.*, t2.student_id
from table1 t1
inner join table2 t2 on (ti.id = t2.id) and (t2.course_id <> 2)

Go with the flow & have fun! Else fight the flow :)
Go to Top of Page
   

- Advertisement -