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 |
|
SteveReed
Starting Member
2 Posts |
Posted - 2008-03-06 : 14:53:47
|
| I want to write SQL statement that will pull out the records from table1 that table2 does not contain. something likeSelect table1.StudentID from table1, table2 WHERE table1.StudentID 'does not contain' table2.StudentIDbut what's the approprate way of writing that statement?Please help!Thank youSteve Reed |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2008-03-06 : 14:59:38
|
| select table1.StudendIDfrom table1left outer join table2 on table1.StudentID = table2.StudentIDwhere table2.StudentID is NULL=======================================Do something for somebody every day for which you do not get paid. -Albert Schweitzer, philosopher, physician, musician, Nobel laureate (1875-1965) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-03-06 : 15:01:24
|
| SELECT ...FROM Table1 t1WHERE NOT EXISTS (SELECT * FROM Table2 t2 WHERE t1.StudentID = t2.StudentID)Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
SteveReed
Starting Member
2 Posts |
Posted - 2008-03-06 : 15:02:22
|
| That works!Thank you so muchSteve Reed |
 |
|
|
|
|
|