I have such a table:
id | content | date
45 | "Lorem" | "2014-09-06"
56 | "Ipsum" | "2013-05-01"
The table has a lot of rows. Now I need to get different year values.
Statement:
SELECT YEAR(`date`) AS `year` FROM `news` GROUP BY `year` ORDER BY `date`
Unfortunately, this solution doesn't use date
index.
My question is if it's a good practice to have a separate year
column and set it before every insert/update and have an index on it?
Or is there a better solution?