Monday, March 19, 2012

List Unused Entries

I am using SQLServer 2000. I have one table (Members) which includes a
MemberID (int) field. I have another table (EventRegs) with a unique
EventID(int) and a foreign key for MemberID. A given MemberID can occur in
more than one row in the EventRegs table. I want to find out which MemberID
values that exist in the Members table that do not occur in any of the rows
in the EventRegs table. Basically, which members are not attending any
events.
I always get tangled up when I try to do this type of query! Can anyone give
me an example to work from?
WayneWayene
SELECT MemberID FROM Members WHERE NOT EXISTS
(SELECT * FROM EventRegs WHERE EventRegs.EventID=Members.MemberID )
"Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
news:Oz30z0MzFHA.1168@.TK2MSFTNGP10.phx.gbl...
>I am using SQLServer 2000. I have one table (Members) which includes a
>MemberID (int) field. I have another table (EventRegs) with a unique
>EventID(int) and a foreign key for MemberID. A given MemberID can occur in
>more than one row in the EventRegs table. I want to find out which MemberID
>values that exist in the Members table that do not occur in any of the rows
>in the EventRegs table. Basically, which members are not attending any
>events.
> I always get tangled up when I try to do this type of query! Can anyone
> give me an example to work from?
> Wayne
>

No comments:

Post a Comment