First a little background: I have an online applicaiton where incoming freshmen apply for campus housing. Part of the app lets them request their rommmate. The roommate requests have to be mutual. (We do random assignments for those that don't request a particular person but that's a different query.) This is an SQL database and i'm using Access 2003 on the front end. I'm open to any options this is just what i've been working with.
Anyway, here's my code
The results give me pretty much what I want except you get duplicates - One row where for A's app requesting B and one for B's app requesting A.
Results:
I basicly only need every other row but am not sure how to do that. I tried experimenting with NOT IN but didn't have much luck.
thanks,
brian
Anyway, here's my code
Code:
SELECT DISTINCT a.FirstName, a.LastName, b.FirstName AS Expr2, b.LastName AS Expr3, a.PriorityDate, b.PriorityDate AS Expr6
FROM dbo.PostApp a LEFT OUTER JOIN
dbo.PostApp b ON a.ID = b.RoommateID AND b.ID = a.RoommateID AND a.Gender = b.Gender
WHERE (a.PriorityDate IS NOT NULL) AND (b.PriorityDate IS NOT NULL)
ORDER BY a.PriorityDate
The results give me pretty much what I want except you get duplicates - One row where for A's app requesting B and one for B's app requesting A.
Results:
Code:
FirstName LastName Expr2 Expr3 PriorityDate Expr6
Cameron Carr Donna Saunders 7/27/2005 7/27/2005
Donna Saunders Cameron Carr 7/27/2005 7/27/2005
Christine Sirna Kara Wilson 7/28/2005 8/2/2005
Kara Wilson Christine Sirna 8/2/2005 7/28/2005
I basicly only need every other row but am not sure how to do that. I tried experimenting with NOT IN but didn't have much luck.
thanks,
brian