View Full Version : union quey but do not want duplicates


Happy YN
08-19-2002, 07:51 AM
I have a query which results in parents of pupils. I have a combo box with a union query which can be either "all" or a particular class. The idea is that by selecting a class, I will only have the parents of pupils in that class but if I select "all" then I will have all the parents in the school. However some parents have more than one child in the school so they come out a number of times in the query result when I select "all" from the combo. Is there any way that I can use the class field as a criteria to limit the parents of pupils in a particular class and yet when I select "all" from the combo it will show me all records but remove the parents which appear more than once (since they have children in a few classes)?

I know how to design the combobox for "all" etc but the problem is the filtering of duplicate parents
Thanks

RV
08-19-2002, 11:34 AM
Seems to me your database is not completely normalized.
However, if your "parents" query only retrieves the parents, try this adaption of your query:

SELECT
.....
UNION
SELECT blabla

becomes
SELECT
.....
UNION
SELECT DISTINCT PARENT

hth,

RV

Happy YN
08-19-2002, 05:01 PM
Thanks for reply. My db is to my knowledge normalised. my parents query had to linked to the classlists in order to use that as a criteria. However I have solved it using 2 queries, firstly one which produced duplicate parents because the had multiple children in the school the I queried that query without the "class' field and set the query properties to unique values =yes. that filtered out duplicate parents. Yours I don't think would work because every record is distinct since the field for class is different
thanks again for your help
happy yn