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 |
|
Bobba Buoy
Starting Member
36 Posts |
Posted - 2003-07-25 : 11:36:31
|
| I want to populate an asp select dropdown with all the people (by unique id) in a roster table that don't appear in a forms table. The two tables are joined by a relationship. Should I use a join, and if so, what is the syntax for the ON clause? For instance: "SELECT * FROM Roster r INNER JOIN Forms f ON ??? WHERE r.TeamID = 10" Or would it be easier to throw them all in the select and then take out the duplicates (I don't know how to 'remove item' in asp)?Thanks!! |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2003-07-25 : 11:45:33
|
| Definitely something for SQL server to do!You are looking at something with NOT IN, NOT EXISTS or (LEFT) OUTER JOIN. Example:SELECT * FROM Roster WHERE TeamID = 10 AND PersonID NOT IN(SELECT PersonID FROM Forms--WHERE TeamID = 10 perhaps?)SELECT r.* FROM Roster rLEFT JOIN Forms fON r.TeamID = f.TeamIDAND r.TeamID = 10WHERE f.PersonID IS NULLOwais |
 |
|
|
|
|
|