Sometime ago this forum helped me with a Union All Select query. I still do not have a handle on this type of query. In this one I have two tables in which a query is run for making name tags. The format for the classmate is:
Firstname
(Maidenname) if any
Lastname
The format for the spouse is:
Firstname
Lastname
The where part is if both are attending the event then the count is 2 otherwise if only one is attending the count is one, which is obvious but I am playing around trying to get this thing to work. As of now I have this query:
[sql]SELECT FirstName, LastName, MaidenName, ClassYear, ClassPhoto, ClassYear AS OrderYear,
LastName AS Sortname, 1 AS SortOrder
FROM Members INNER JOIN Attending ON Members.ID = Attending.ID
WHERE EventAttend=True
UNION ALL SELECT Spouse, LastName, ”,
IIF(Spouse = ”,Classyear,”),
IIF(MaidenName = ‘(Spouse)’,”,”), ClassYear,
Lastname, 2 As SortOrder
FROM Members INNER JOIN Attending ON Members.ID = Attending.ID
WHERE Spouse ” AND EventAttend=True
ORDER BY OrderYear, SortName, SortOrder[/sql]
However, with this query, both Classmate and Spouse show up even though the record shows that only one will be in attendance. So I tried inserting this: IIF(NumAttend=1,1,NumAttend). But can’t seem to tie to the query to be effective.
Any ideas would be great. Thanx.