H
haydnw
*SQL at bottom of post*
Hi,
I have a table which lists people (tblContacts,
PK/FK=lngContactID), a table which lists events
(tblEvents, PK/FK=lngEventID) and a join table which lists
invitations to events (tblEventAttendance FK=lngContactID
& lngContactID).
My problem is that I'm currently designing a form where,
once one set of invitations have been sent, extra people
can be invited. To do this, I need to create a list of
people to select from, and this requires a query which
shows Contacts:
a) who have not been already invited to the event in
question (ie tblEventAttendance.lngEventID <>Forms!
frmEvent!txtlngEventID).
b) who have never been invited to an event before
a) is fine, and I can use SELECT DISTINCT to only show
each Contact once. My problem is that this doesn't satisfy
b). People who have never been invited to an event have no
records in tblEventAttendance and so the query does not
pick them up.
If I make a left join between tblContacts and
tblEventAttendance, then my results now include people
who've never been invited to any event, but also include
all the people who have already been invited to the event
in question.
What I need is some sort of way to say 'All people who've
never been invited to an event PLUS if people have been
invited to an event only include them if it's not the
current event'.
I've explained this really badly but I've re-written three
times now! I hope someone can understand and maybe point
me in the right direction.
H
(SQL below)
==================================================
Current query which picks up all people who've been
previously invited to an event, but not invited to the
event in question:
SELECT DISTINCT tblContacts.lngContactID
FROM tblContacts INNER JOIN tblEventAttendance ON
tblContacts.lngContactID = tblEventAttendance.lngContactID
WHERE (((tblEventAttendance.lngEventID)<>[Forms]!
[frmEvents]![txtlngEventID];
But this doesn't show people who've never been invited to
any events!
Hi,
I have a table which lists people (tblContacts,
PK/FK=lngContactID), a table which lists events
(tblEvents, PK/FK=lngEventID) and a join table which lists
invitations to events (tblEventAttendance FK=lngContactID
& lngContactID).
My problem is that I'm currently designing a form where,
once one set of invitations have been sent, extra people
can be invited. To do this, I need to create a list of
people to select from, and this requires a query which
shows Contacts:
a) who have not been already invited to the event in
question (ie tblEventAttendance.lngEventID <>Forms!
frmEvent!txtlngEventID).
b) who have never been invited to an event before
a) is fine, and I can use SELECT DISTINCT to only show
each Contact once. My problem is that this doesn't satisfy
b). People who have never been invited to an event have no
records in tblEventAttendance and so the query does not
pick them up.
If I make a left join between tblContacts and
tblEventAttendance, then my results now include people
who've never been invited to any event, but also include
all the people who have already been invited to the event
in question.
What I need is some sort of way to say 'All people who've
never been invited to an event PLUS if people have been
invited to an event only include them if it's not the
current event'.
I've explained this really badly but I've re-written three
times now! I hope someone can understand and maybe point
me in the right direction.
H
(SQL below)
==================================================
Current query which picks up all people who've been
previously invited to an event, but not invited to the
event in question:
SELECT DISTINCT tblContacts.lngContactID
FROM tblContacts INNER JOIN tblEventAttendance ON
tblContacts.lngContactID = tblEventAttendance.lngContactID
WHERE (((tblEventAttendance.lngEventID)<>[Forms]!
[frmEvents]![txtlngEventID];
But this doesn't show people who've never been invited to
any events!