[thelist] MySQL Query problem: unique vals from two fields

Pringle, Ron RPringle at aurora-il.org
Wed Nov 22 11:17:52 CST 2006


Worked like a charm thanks! I obviously have much to learn. Anthony,
thanks for the pointer on views. I will look into those as well!

Have a good Thanksgiving all!


Matt wrote:

Fresh out of blunt objects, but maybe I can help with the query.

select distinct year(exEndDate) as exhibitYear
from tbl_exhibitDates
where exEndDate < current_date()
select distinct year(exStartDate)
from tbl_exhibitdates
where exStartDate < current_date()

This *should* return only distinct years, because it is union and not
union all. However, give it a try in your DB of choice and if it is
duping years that exist in both sets, we will have to filter those out
in the where clause of the second query.


Matt Warden
Cleveland, OH, USA

More information about the thelist mailing list