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.
| Author |
Topic |
|
mshen
Starting Member
8 Posts |
Posted - 2004-09-23 : 22:41:46
|
| Hi Friend,I have two table: student table and class tablestudent table like this:id name1 tony2 john3 darren4 mark...class table like thisis class_id student_id1 1 12 1 33 2 34 2 4....I want to get the the student list who do not select classs 2.I want to know how to write the SQL statement.Please help me.I write it like this but it doesn't work.select s.* from student s,class c where s.id=c.student_id and c.class_id<>2why?Thanks a lot. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-09-23 : 23:07:50
|
| Condier it without the and c.class_id<>2.Now take out the ones where c.class_id=2.That's why you get that resultset.To do this you need a left outer join or a not exists clause.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|