I have 3 tables: Organization, OrgSORT, and Membership. I have to base a query on those 3 tables where the OrgSORT.SortCodeID is either (6, 15, 51, or 52) OR the Membership.MembershipType is 2 BUT NOT the OrgSORT.SortCodeID is 50. An organization can have multiple sort codes and if any of the sort code's is 50, regardless of the other values, the organization cannot be returned in the search result.
Currently I have the SQL statement but for some reason the omit part of it does not work:
SELECT Organization.OrgID, Organization.OrgName, OrgSORT.SORTCodeID, Membership.MembershipType
FROM Organization, OrgSORT, Membership
WHERE (OrgSORT.SORTCodeID=6 OR OrgSORT.SORTCodeID=15 OR OrgSORT.SORTCodeID=51 OR OrgSORT.SORTCodeID=52 OR Membership.MembershipType=2) AND (OrgSORT.SORTCodeID<>50)
AND (Membership.OrgID=Organization.OrgID) AND (OrgSORT.OrgID=Organization.OrgID)
If someone could form a SQL query for me I would really appreciate that.
Thanks,
Arthur
Currently I have the SQL statement but for some reason the omit part of it does not work:
SELECT Organization.OrgID, Organization.OrgName, OrgSORT.SORTCodeID, Membership.MembershipType
FROM Organization, OrgSORT, Membership
WHERE (OrgSORT.SORTCodeID=6 OR OrgSORT.SORTCodeID=15 OR OrgSORT.SORTCodeID=51 OR OrgSORT.SORTCodeID=52 OR Membership.MembershipType=2) AND (OrgSORT.SORTCodeID<>50)
AND (Membership.OrgID=Organization.OrgID) AND (OrgSORT.OrgID=Organization.OrgID)
If someone could form a SQL query for me I would really appreciate that.
Thanks,
Arthur