I have a mysql table with records dating from 2006 to present (and ongoing), all with datetime stamps
What is the smartest/easiest way to extract all YEARS only and make a pagination link for each year (dynamically)?
Like this: 2006 2007 2008 2009 2010 2011 2012
Isn’t this too clumsy and uses too many resources for that simple task?:
@mysql_query("SELECT YEAR(date) AS yearonly FROM table GROUP BY yearonly");
I think your solution is OK.
Using
select distinctis another possibility