Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL - find all rows where eventid includes 56

Status
Not open for further replies.

wishwishwish

IS-IT--Management
Mar 18, 2009
1
GB
I have 3 tables - Volunteers, Events, EventVolunteers

I want to find all the volunteers who have have volunteered for eventid 56. For those volunteers who have volunteered for eventid 56 I also want to see all the other events they have volunteered for.

So - I can do:

SELECT Volunteers.Name
FROM Volunteers INNER JOIN (Events INNER JOIN EventVolunteers ON Events.EventID = EventVolunteers.EventId) ON Volunteers.ID1 = EventVolunteers.VolunteerID
WHERE (((Events.EventID)=56));

This gives me all the volunteer names who have volunteered for eventid 56 - but I can't work out how to get the other events they have volunteered for too.

Any help would be really really appreciated.

thank you
 
SELECT Volunteers.Name,EventVolunteers.EventId
FROM Volunteers
inner join EventVolunteers
on EventVolunteers.VolunteerID=Volunteers.VolunteerID
inner join(Select distinct VolunteerID from EventVolunteers where EventId=56 )event56
on event56.VolunteerID = EventVolunteers.VolunteerID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top