Saturday, 10 August 2013

Join two tables with mysql and order by date

Join two tables with mysql and order by date

I have looked at many supposed solutions to this problem, but I still
cannot get this to work.
SELECT Year FROM (SELECT DISTINCT YEAR(detDate1) AS Year
FROM growl_details WHERE publish = 'y' AND pubNews = 'y'
UNION
SELECT DISTINCT YEAR(detDate1) AS Year FROM growl_pl_details
WHERE publish = 'y' AND pubNews = 'y') AS t ORDER BY 'Year' ASC
I have two tables, growl_details and growl_pl_details, I am trying to get
them to display just the years which information exists, this will then be
used to create a table with links to data pages concerned with that year.
Obviously I want the years to show in order, but the above code seems to
order them individually and they follow on from each other..
Any ideas?

No comments:

Post a Comment