Maybe that's why I can never figure them out ;-)
My [BOD List Query] brings back all Board Members that show
[GroupName]="Board of Directors" and [GroupEnd] is null. That gives me all
current Board Members. And even if Board Members don't meet any of the other
criteria in the WHERE statement, I still want Board Members. They trump all.
Contacts.MemberStatusID=1 or 6 (that's "Current-Active" or "Lifetime")
Contacts.MemberTypeID=1 or 5 (that's "Handler" or "Local Support")
Contacts.MemberOption=1 (that's a "true" member).
Next after Board Members, I want all members where Contacts.MemberOption=1
AND Contacts.MemberStatusID=1 or 6 AND Contacts.MemberTypeID=1 or 5. That
will give me Board Members no matter what, as well as "true" members that are
have either a Handlers or Local Support membership with a status of
Current-Active or "Lifetime".
Basically what has happened is that I had a nice MemberListQuery and then
discovered that we needed Board Members included in the Member List. Some
Board Members are "true" members (already on the list) and some need to be
added. I want Board Members added to the list if they weren't already on it,
without duplicating a listing if a person is both a "true" member and a Board
Member.
MemberListQuery:
SELECT [LastName] & ", " & Nz([NickName],[FirstName]) AS [Member Name],
Contacts.MailingAddress1, [City1] & ", " & [StateOrProvince1] & " " &
[PostalCode1] AS Address, Contacts.HomePhone, [WorkPhone] & ("
x"+[WorkExtension]) AS WorkPhExt, Contacts.MobilePhone, Contacts.Spouse,
FldConcat("AnimalNB","Animal","ContactID",[ContactID]) AS [Animal List],
MemberStatus.MemberStatusID, MemberType.MemberTypeID, Contacts.MemberOption
FROM (Contacts INNER JOIN MemberStatus ON Contacts.MemberStatusID =
MemberStatus.MemberStatusID) INNER JOIN MemberType ON Contacts.MemberTypeID =
MemberType.MemberTypeID
(And then I never really got the WHERE statement correct...)
[BOD List Query] sql:
SELECT [LastName] & ", " & Nz([NickName],[FirstName]) AS [Member Name],
Contacts.MailingAddress1, [City1] & ", " & [StateOrProvince1] & " " &
[PostalCode1] AS Address, Contacts.HomePhone, [WorkPhone] & ("
x"+[WorkExtension]) AS WorkPhExt, Contacts.MobilePhone, Contacts.Spouse,
FldConcat("AnimalNB","Animal","ContactID",[Contacts].[ContactID]) AS [Animal
List], Groups.GroupName, GroupMembers.GMemberEnd, GroupMembers.GroupID
FROM Contacts INNER JOIN (Groups INNER JOIN GroupMembers ON Groups.GroupID =
GroupMembers.GroupID) ON Contacts.ContactID = GroupMembers.ContactID
WHERE (((Groups.GroupName)="Board of Directors") AND
((GroupMembers.GMemberEnd) Is Null))
ORDER BY [LastName] & ", " & Nz([NickName],[FirstName]);
I tried a union join but the tables in the 2 queries are different...
Thanks for the help!
MGFoster said:
Can you state, in English, the criteria? Like "I want all records w/
MemberOption of 1 and if the MemberTypeID = ? then ... etc." It's
usually best to start from basics on a complex Boolean evaluation.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
Close- thanks!
I've gone with:
WHERE Contacts.MemberOption=1 AND ((Contacts.MemberStatusID=1 AND
Contacts.MemberTypeID=1) OR (Contacts.MemberStatusID=6 AND
Contacts.MemberTypeID=5) OR (Contacts.MemberStatusID=1 AND
Contacts.MemberTypeID=5) OR [BOD List Query].[GroupName]="Board of Directors")
I had 2 records returned that should not have been and 1 not returned that
should have been:
Should not be returned:
MemberOption =1, MemberStatusID=1, MemberTypeID=2 (MemberTypeID should only
be 1 or 5)
MemberOption=1, MemberStatusID=2 (Member Status should only equal 1, unless
the person is Board of Directors, which she's not), MemberTypeID=1
Should have been included:
MemberOption=3 (normally should only =1, but Board of Directors trumps all),
MemberStatusID = 1, MemberTypeID=4 (but ditto of BOD trumping all).
Although I can see why the record that should have been included wasn't, I
don't know how to fix it. And I can't see why the 2 records that were
included but shouldn't have been showed up.
I'd appreciate any more WHERE sql suggestions. Thanks!
:
Stephanie wrote:
Hi. I'm struggling to get my query to bring back the information I want it to:
Here's the fields with the criteria
Contacts.MemberOption Contacts.MemberStatusID Contacts.MemberOption
1 AND 1 AND 1 OR
1 AND 6 AND 5 OR
1 AND 1 AND 5
And heres the big OR at the end
sqry.GroupName="Board of Directors"
So I have:
WHERE (((Contacts.MemberOption)=1) AND ((Contacts.MemberStatusID)=1) AND
((Contacts.MemberTypeID)=1)) OR (((Contacts.MemberOption)=1) AND
((Contacts.MemberStatusID)=6) AND ((Contacts.MemberTypeID)=5)) OR
(((Contacts.MemberOption)=1) AND ((Contacts.MemberStatusID)=1) AND
((Contacts.MemberTypeID)=5))
But can't seem to get the correct information returned when I try to throw
OR sqry.GroupName="Board of Directors"
into the mix. Anyway I try to add the last OR, EVERY record is returned.
I appreciate a little syntax help.
Thanks.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
WHERE Contacts.MemberOption=1
AND ((Contacts.MemberStatusID=1
AND Contacts.MemberTypeID=1)
OR (Contacts.MemberStatusID=6
AND Contacts.MemberTypeID=5)
OR (Contacts.MemberStatusID=1
AND Contacts.MemberTypeID=5)
OR sqry.GroupName="Board of Directors")
It may be that you need AND sqry.GroupName="Board of Directors" instead
of OR sqry.GroupName="Board of Directors", in which case the WHERE
clause would look like this:
WHERE Contacts.MemberOption=1 AND sqry.GroupName="Board of Directors"
AND ((Contacts.MemberStatusID=1
AND Contacts.MemberTypeID=1)
OR (Contacts.MemberStatusID=6
AND Contacts.MemberTypeID=5)
OR (Contacts.MemberStatusID=1
AND Contacts.MemberTypeID=5))
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQxiZAoechKqOuFEgEQIlpwCggVVJvHiIPfh4A367aEPk4+sq8+AAoO0E
vpJjmtKbZxuT8yZAWZCW7gQd
=dk1g
-----END PGP SIGNATURE-----