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
 SQL Server Development (2000)
 Selecting Entries from a JOIN

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 r
LEFT JOIN Forms f
ON r.TeamID = f.TeamID
AND r.TeamID = 10
WHERE f.PersonID IS NULL


Owais

Go to Top of Page
   

- Advertisement -